News for hackers. Stuff that matters.
Re:Lisp-Stick on a Python by hamandcheese on Tuesday November 15, 2022 @01:52AM (#33606081)
> 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?

Re:Lisp-Stick on a Python by Jtsummers on Tuesday November 15, 2022 @02:04AM (#33606160)
The 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 (most of the way down that page)
Re:Lisp-Stick on a Python by zelphirkalt on Tuesday November 15, 2022 @04:25AM (#33607048)
Watch 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.
Re:Lisp-Stick on a Python by crdrost on Tuesday November 15, 2022 @10:37AM (#33610433)
Oh 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

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