On Sun, Aug 2, 2009 at 3:28 PM, John Harrop wrote:
> On Sun, Aug 2, 2009 at 5:48 AM, James Sofra wrote:
>
>>
>> (defn get-tile [[x y] maze]
>> (if (tile-in-bounds? [x y] maze)
>>((maze y) x)))
>
>
> (defn get-tile [[x y] maze]
> (get (get maze y) x))
>
While you're at it, why not: (get-i
Thanks John! Those suggestions are really helpful, the short-
circuiting 'and' is good to remember.
> Might simplify this a bit using assoc-in.
Yeah this works, nice, thanks.
(defn update-tile [[x y] maze value]
(if (tile-in-bounds? [x y] maze)
(assoc-in maze [y x] value)
maze))
Chee
On Sun, Aug 2, 2009 at 5:48 AM, James Sofra wrote:
> (defn tile-in-bounds? [[x y] maze]
> (let [h (count maze)]
>(if (and (>= y 0) (>= x 0) (< y h))
> (if (< x (count (maze y)))
>true
(defn tile-in-bounds? [[x y] maze]
(and (>= y 0) (>= x 0) (< y (count maze)) (< x (coun
Hi all,
I am new to functional programming and thought this might be
interesting to others to see my approach to this kind a recursion
problem. I found this problem hard to think through, does anyone have
any suggestions for simpler solution to this type of problem?
I needed a recursive backtrac