5 ms·
Aha ! Now in, while m+i is less than the length of S, do: if W[i] = S[m + i], if i equals the (length of W)-1, return
by prollyignored 13y ago
Aha !
Now in,
while m+i is less than the length of S, do:
if W[i] = S[m + i],
if i equals the (length of W)-1,
return m
let i ← i + 1
....
How would I implement the `return m` part ?
- dizzystar 13y agoThere is no explicit return value because the functions aren't functions: they are values, thus the result of the algorithm is bound to the value that is bound to the function. When you write: (defn square [x] (* x x)) You are really writing: (def square (fn [x] (* x x))) and x * x is bound to the value of square. There would be no logical reason to have an explicit return value here.
- danneu 13y agoIt's pretty much the same as this: (loop [n 0] (if (= n 10) n ; true case: return n (recur (inc n)))) ; false case: loop with n++ ;=> 10