Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lispインタープリタ勉強会に参加したので

 Lispインタープリタ勉強会に参加したので

LT駆動開発09の発表資料です。
https://github.com/LTDD/Sessions/wiki/LT%E9%A7%86%E5%8B%95%E9%96%8B%E7%99%BA09

中身はあまりない。
解説はこっちに。

http://blog.eiel.info/blog/2014/12/08/ltdd-09-mylisp/

Tomohiko Himura

December 07, 2014
Tweet

More Decks by Tomohiko Himura

Other Decks in Programming

Transcript

  1. (+ 1 2 3) • JavaScript • [“+”, 1, 2

    ,3] • Haskell • List [Symbol “+”, Number 1, Number 2, Number 3] ಈతܕγεςϜʹ᱐͞Εͯͨ
  2. ͝·͔͢ͳΒ… n1 = Number 1 n2 = Number 2 n3

    = Number 3 sPlus = Symbol "+" -JTU<T1MVT O O O>
  3. ܕఆٛ data Value = Func ([Value] -> Value) | List

    [Value] | Symbol String | Number Int
  4. ධՁ evaluate :: Env -> Value -> Value evaluate _

    (Number x) = Number x evaluate env (Symbol x) = fromMaybe nil $ HM.lookup x env evaluate _ (List []) = nil evaluate env (List (x:xs)) = case x of Symbol x' -> case fromMaybe nil $ HM.lookup x' env of x''@(Func _) -> apply env x'' xs _ -> nil _ -> nil
  5. + ͷ࣮૷ plus = Func plus' where number (Number x)

    = x plus' = Number . sum . map number