Arc Forumnew | comments | leaders | submitlogin
1 point by jsgrahamus 2336 days ago | link | parent

That's shorter. What are any other differences? I copied the first one from the docs and am not sure what the nil was for.


3 points by zck 2336 days ago | link

They're very similar. Check out for some better documentation, but it boils down to this:

  (whilet var test ...)
loops until (no (test)) is true -- until (test) returns 'nil. Each loop through, var is bound to the value of (test). On the other hand,

  (whiler var expr endval ...)
loops until (is (expr) endval) is true. Similarly, each loop through, var is bound to the value of (expr).

So every time you have a call to

  (whiler value (function) nil ...)
You can replace that with

  (whilet value (function) ...
An example of when you would want to use whiler is:

  (whiler input (readline) "quit" (do-stuff-with-input-from-user input))


1 point by jsgrahamus 2335 days ago | link

Good explanation. Thanks.