Lisp like s-expressions in haskell
Kind of interesting to write lisp like code in haskell. Note, all of this is valid haskell:
Prelude> ((+) ((*) 1 2) 10)
12
Prelude> (1 * 2) + 10
12
Prelude Text.Printf> (printf "%d\n" 5)
5
Prelude Text.Printf> printf "%d %d\n" 1 2
1 2
Prelude Text.Printf> ((printf "%d %d\n" 1) 2)
1 2
Of course, you have to match up the arguments in haskell accordingly; not all functions take a just a list like you might find in common lisp.
Prelude> ((+) ((*) 1 2) 10)
12
Prelude> (1 * 2) + 10
12
Prelude Text.Printf> (printf "%d\n" 5)
5
Prelude Text.Printf> printf "%d %d\n" 1 2
1 2
Prelude Text.Printf> ((printf "%d %d\n" 1) 2)
1 2
Of course, you have to match up the arguments in haskell accordingly; not all functions take a just a list like you might find in common lisp.
Comments