Jump to content

Search the Community

Showing results for tags 'abelson'.

  • 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. Good evening, everyone. I've recently started to watch the Abelson-Sussman MIT lectures on computer science (mostly because I find them very interesting, not because they have much to do with what I do) and I've ran across this piece of code to create a counter: (define make-counter (lambda (N) (lambda () (set! N (1+ N)) N))) (define c1 (make-counter 1)) (define c2 (make-counter 10)) The explanation concerning the mentioned code starts at around the 48 minute mark. The syntax is not that of AutoLISP and neither that of Common Lisp, I believe, mostly because it's a fragment taken from the middle of a lecture and there's a good reason for the way the code above is written. Anyway, what is supposed to happen is that when you run (c1) for the first time you get a 2; for the second time you get a 3 etc.; when you run (c2) you get (regardless of when you run (c1)) 11; the next time you get 12 etc. I attempted to translate it to AutoLISP: (defun make-counter (N) (lambda () (setq N (1+ N)) N) ) (defun c1 () ((make-counter 1)) ) (defun c2 () ((make-counter 10)) ) The problem is that this does not work. When I attempt to evaluate this with N being nil I get an error. If N is preset to some integer/real then it will be incremented, regardless of calling c1 or c2. I'd like to know if I'm doing something wrong or if this is something that I simply cannot do in AutoLISP. Can this piece of code run the way Sussman shows it in his lecture? Is there a catch here? This is not a matter of life or death, obviously, and I'm not interested in another piece of code that works as a counter (though I'd be delighted to see whichever ones you guys came up withd) since this is something I can easily get around. All I wanted is to know if this can work in AutoLISP and, if so, how. Thank you all!
×
×
  • Create New...