Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn fp_fun
- ([x y row col vec]
- (if (or (< x 0)
- (< y 0)
- (>= x row)
- (>= y col))
- 0)
- (if (= vec[x y] "@")
- 1)
- (if (= vec[x y] "#")
- 0)
- (def x1 (+ x 1))
- (def y2 (- y 1))
- (if (= ( (fp_fun x y2 row col vec)) 1 )
- 1)
- (if (= ( (fp_fun x1 y row col vec)) 1 )
- 1)
- 1)
- (println "!" x y)
- 0) )
- ((defn [args here]
- expression-that-returns-the-result-of-this-function-here)
- (defn
- ([one-arg]
- result-expression-here)
- ([fist-arg second-arg]
- other-result-expression-here))
- (println "!" x y)
- 0
- (defn fp_fun
- ;; this function always takes 5 args, so prefer the basic form
- ([x y row col vec]
- ;; this first expression does absolutly nothing and it totally ignored
- (if (or (< x 0)
- (< y 0)
- (>= x row)
- (>= y col))
- 0)
- ;; this next expression is also ignored, only the last value in a function determines it's result
- (if (= vec[x y] "@")
- 1)
- ;; so this one does nothing as well
- (if (= vec[x y] "#")
- 0)
- ;; these two define some global variables
- ;; using def inside a function is almost always better done with a let expression
- (def x1 (+ x 1))
- (def y2 (- y 1))
- ;; this will always run because none of the above statements cause the function to
- ;; stop and return it's value early.
- (if (= ( (fp_fun x y2 row col vec)) 1 )
- 1)
- ;; and then the stack will overflow before we get here
- (if (= ( (fp_fun x1 y row col vec)) 1 )
- 1)
- 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement