4 ms·
> This means roughly that if you understand enough Lisp to understand this program Any recommendations on good resources for learning Lisp to a degree that thi
by hamandcheese 4y ago
> This means roughly that if you understand enough Lisp to understand this program
Any recommendations on good resources for learning Lisp to a degree that this program is understandable?
- Jtsummers 4y agoThe Little Schemer would be a good resource. Some here may disagree, though. It uses a Socratic dialogue style that rubs some people the wrong way. But here is Norvig's Python eval for a Lisp: def eval(x, env=global_env): "Evaluate an expression in an environment." if isinstance(x, Symbol): # variable reference return env.find(x)[x] elif not isinstance(x, List):# constant return x op, *args = x if op == 'quote': # quotation return args[0] elif op == 'if': # conditional (test, conseq, alt) = args exp = (conseq if eval(test, env) else alt) return eval(exp, env) elif op == 'define': # definition (symbol, exp) = args env[symbol] = eval(exp, env) elif op == 'set!': # assignment (symbol, exp) = args env.find(symbol)[symbol] = eval(exp, env) elif op == 'lambda': # procedure (parms, body) = args return Procedure(parms, body, env) else: # procedure call proc = eval(op, env) vals = [eval(arg, env) for arg in args] return proc(*vals) https://norvig.com/lispy.html https://norvig.com/lispy.html (most of the way down that page)
- cpach 4y agohttp://www.paulgraham.com/rootsoflisp.html http://www.paulgraham.com/rootsoflisp.html https://sep.yimg.com/ty/cdn/paulgraham/jmc.ps https://sep.yimg.com/ty/cdn/paulgraham/jmc.ps http://www-formal.stanford.edu/jmc/recursive.html http://www-formal.stanford.edu/jmc/recursive.html
- zelphirkalt 4y agoWatch Will Byrd's MiniKanren Uncourse. The topic sounds off, but he takes a few videos to get there, making a Lisp on the way, explaining this, or a variant of it. Should be within the first 4 videos.
- crdrost 4y agoOh what a fun question! So, the first thing is, what's the essential difficulty versus the noise: Lisp has two features which enable the evaluator to work. The first is quotation, which means that you can put a little apostrophe before some code and then it saves that code as a data structure, rather than implicitly evaluating it. The second goes by the overfancy name “homoiconicity”, that data structure is actually just singly linked list consumed by “car” (“first”) and “cdr” (“rest”) operations. You can focus on understanding those two aspects pretty quickly, and then there are many tutorials about building your own Lisp that will get you there in an afternoon, if you'd like. Or, you can take the royal road to this expression, in all of its cheesy 1980s glory: https://youtube.com/playlist?list=PLE18841CABEA24090 https://youtube.com/playlist?list=PLE18841CABEA24090 It's lecture 7A where this specific program gets explicitly dissected by Sussman, wearing a fez. If he seems familiar, you might have watched Strange Loop 2011’s “We Really Don't Know How To Compute”, https://youtu.be/HB5TrK7A4pI https://youtu.be/HB5TrK7A4pI