You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is map(), of course, and you can build a sequential one, if you want, by using recursion:
let while = fn(cond, body) {
if (!cond()) { return NO! }
body()
while(cond, body)
}
let i = 1
while(fn() { 10 >= i }, fn() {
puts("This will be printed ten times")
i = i + 1
})
Of course, this can blow up the stack, and also will be pretty slow, however I managed this way to run the following code:
In "just" two and a half minutes, where timeseq() is based on whileseq() which is the above, and mapseq() runs forseq() which is again based on whileseq(). So... Not so bad. Well, terrible, but still...
So what if you need to iterate over a list with side effects? What if you want to sort the list? What if there is an error halfway through and you need to abort cleanly, like a device went offline and now you need to stop processing and not pound the poor thing with a million further requests? map() is a nice tool, but it has a lot of limitations in the real world. Generally it has to be used judiciously to avoid runaway code.
I have not see any loop constructs in the OK? language, how do I do loop logic in OK? language?
The text was updated successfully, but these errors were encountered: