News for hackers. Stuff that matters.
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)

There are no comments on this comment yet.