File tree Expand file tree Collapse file tree 6 files changed +93
-49
lines changed Expand file tree Collapse file tree 6 files changed +93
-49
lines changed Original file line number Diff line number Diff line change 11(defn main [world undocumented]
22 '(initial_state step_fn))
33
4- (defn world-map [world]
5- (head world))
6-
7- (defn lambda-man [world]
8- (nth world 2 ))
9-
10- (defn direction [actor]
11- (nth actor 3 ))
12-
13- (defn location [actor]
14- (nth actor 2 ))
15-
16- (def UP 0 )
17- (def LEFT 1 )
18- (def DOWN 2 )
19- (def RIGHT 3 )
20- (def DIRECTIONS [UP RIGTH DOWN LEFT UP RIGHT])
21-
22-
23- (def WALL 0 )
24- (def EMPTY 1 )
25- (def PILL 2 )
26- (def POWER-PILL 3 )
27- (def FRUIT 4 )
28- (def LM 5 )
29- (def GHOST 6 )
30-
31- (def at [world-map x y]
32- (nth (nth (world-map ) y) x))
33-
34- (def neighbour [pos direction]
35- (let [x (head pos)
36- y (tail pos)]
37- (if (== direction UP)
38- '(x, (prev y))
39- (if (== direction LEFT)
40- '((prev x), y)
41- (if (== direction DOWN)
42- '(x, (succ y))
43- '((succ x), y))))))
44-
45- (defn next [direction]
46- (nth DIRECTIONS (succ direction)))
47-
48- (defn back [direction]
49- (if (== direction UP)
50- RIGHT
51- (nth DIRECTIONS (pred direction))))
52-
534(def initial_state
545 0 )
556
Original file line number Diff line number Diff line change 1+ (def UP 0 )
2+ (def LEFT 1 )
3+ (def DOWN 2 )
4+ (def RIGHT 3 )
5+ (def DIRECTIONS [UP RIGTH DOWN LEFT UP RIGHT])
6+
7+
8+ (def WALL 0 )
9+ (def EMPTY 1 )
10+ (def PILL 2 )
11+ (def POWER-PILL 3 )
12+ (def FRUIT 4 )
13+ (def LM 5 )
14+ (def GHOST 6 )
15+
16+
17+ (defn world-map [world]
18+ (head world))
19+
20+ (defn lambda-man [world]
21+ (nth world 2 ))
22+
23+ (defn direction [actor]
24+ (nth actor 3 ))
25+
26+ (defn location [actor]
27+ (nth actor 2 ))
28+
29+ (defn at [world-map x y]
30+ (nth (nth (world-map ) y) x))
31+
32+ (defn neighbour [pos direction]
33+ (let [x (head pos)
34+ y (tail pos)]
35+ (if (== direction UP)
36+ '(x, (prev y))
37+ (if (== direction LEFT)
38+ '((prev x), y)
39+ (if (== direction DOWN)
40+ '(x, (succ y))
41+ '((succ x), y))))))
42+
43+ (defn next [direction]
44+ (nth DIRECTIONS (succ direction)))
45+
46+ (defn back [direction]
47+ (if (== direction UP)
48+ RIGHT
49+ (nth DIRECTIONS (pred direction))))
Original file line number Diff line number Diff line change 1+ (defn nth [list pos]
2+ (if (== pos 0 ) (head list) (nth (tail list) (pred pos)))
3+
4+ (defn succ [x]
5+ (add x 1 ))
6+
7+ (defn pred [x]
8+ (sub x 1 ))
Original file line number Diff line number Diff line change 1+ /target
2+ /classes
3+ /checkouts
4+ pom.xml
5+ pom.xml.asc
6+ * .jar
7+ * .class
8+ /.lein- *
9+ /.nrepl-port
Original file line number Diff line number Diff line change 1+ (defproject tosexp " 0.1.0-SNAPSHOT"
2+ :description " FIXME: write description"
3+ :url " http://example.com/FIXME"
4+ :license {:name " Eclipse Public License"
5+ :url " http://www.eclipse.org/legal/epl-v10.html" }
6+ :dependencies [[org.clojure/clojure " 1.6.0" ]
7+ [org.clojure/core.match " 0.2.1" ]])
Original file line number Diff line number Diff line change 1+ (ns tosexp.core
2+ (:use [clojure.core.match :only (match )])
3+ (:require [clojure.walk :as w]))
4+
5+ (defn transform [form]
6+ (match
7+ [(if (list? form) (vec form) form)]
8+
9+ [['+ a b]] (list 'Add (transform a) (transform b))
10+ [(a :guard number?)] (list 'Const a)
11+ ))
12+
13+ (defn mytest []
14+ (transform
15+ '(+ 1 2 )))
16+
17+ (defn foo
18+ " I don't do a whole lot."
19+ [x]
20+ (println x " Hello, World!" ))
You can’t perform that action at this time.
0 commit comments