Jump to content

Search the Community

Showing results for tags 'odd'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 1 result

  1. Hello, I would apprecite some reactions on the following tools that I made. Reading about Clojure I came across functionality that is not standard available in AutoLisp. After some thinking I programmed it myself. First 2 functions which do what they are supposed to do: (defun even? (n) (and (= (type n) 'INT) (= (rem n 2) 0))) (defun odd? (n) (and (= (type n) 'INT) (/= (rem n 2) 0))) The questionmark in the functionname seems appropriate. So what to do when you want to filter a list of integers against one of these functions? I constructed the following: (defun filter (f l / a) (foreach i l (if (apply f (list i)) (setq a (append a (list i))))) a) To get you started use the following two commands: (defun c:etest () (filter 'even? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) (defun c:otest () (filter 'odd? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) Although short already I wonder if the filter routine could be made more elegant/more logical. One can extend the library with all kinds of name? functions, provided that return T or nil on every call. The questionmark and the name 'filter' are used for logic readability. Try to make a functon that returns T if a value is of type 'STR, otherwise nil. Next use it with the filter function. It's fun and would like to see the variations that you come up with. Regards, André
×
×
  • Create New...