• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 16th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. (defn fp_fun
2.   ([x y row col vec]
3.    (if (or (< x 0)
4.            (< y 0)
5.            (>= x row)
6.            (>= y col))
7.      0)
8.    (if (= vec[x y] "@")
9.      1)
10.    (if (= vec[x y] "#")
11.      0)
12.    (def x1 (+ x 1))
13.    (def y2 (- y 1))
14.    (if (= ( (fp_fun x y2 row col vec)) 1  )
15.      1)
16.    (if (= ( (fp_fun x1 y row col vec)) 1  )
17.      1)
18.    1)
19.   (println "!" x y)
20.   0) )
21.
22. ((defn [args here]
23.    expression-that-returns-the-result-of-this-function-here)
24.
25. (defn
26.   ([one-arg]
27.    result-expression-here)
28.   ([fist-arg second-arg]
29.    other-result-expression-here))
30.
31. (println "!" x y)
32.
33. 0
34.
35. (defn fp_fun
36.   ;; this function always takes 5 args, so prefer the basic form
37.   ([x y row col vec]
38.
39.    ;; this first expression does absolutly nothing and it totally ignored
40.    (if (or (< x 0)
41.            (< y 0)
42.            (>= x row)
43.            (>= y col))
44.      0)
45.
46.    ;; this next expression is also ignored, only the last value in a function determines it's result
47.    (if (= vec[x y] "@")
48.      1)
49.
50.    ;; so this one does nothing as well
51.    (if (= vec[x y] "#")
52.      0)
53.
54.    ;; these two define some global variables
55.    ;; using def inside a function is almost always better done with a let expression
56.    (def x1 (+ x 1))
57.    (def y2 (- y 1))
58.
59.    ;; this will always run because none of the above statements cause the function to
60.    ;; stop and return it's value early.
61.    (if (= ( (fp_fun x y2 row col vec)) 1  )
62.      1)
63.
64.    ;; and  then the stack will overflow before we get here
65.    (if (= ( (fp_fun x1 y row col vec)) 1  )
66.      1)
67.    1))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top