Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
Get HideMyAss! VPN, PC Mag's Top 10 VPNs of 2016 for 55% off for a Limited Time ×

Comment Re:Mmmm, Kay. (Score 1) 439

This is the idea: let x=the list of all incoming messages. Let f be a function that takes a message and the last result, and produces a result, that is some actions and a state. Now, the code for a client is foldr1 f x. Of course, the fun is in programming the function f, but that is why an infinite lazy list is awesome. You don't have to manually make the code for waiting for the next message etc, all that boring stuff no useful person wants to write anyway.

This example is extremely simplified of course, but it's the general idea. I have an IRC bot that operates basically on that principle. It is an infinite loop of taking the next message and using it. Since it is lazy, it doesn't keep looping super fast, it only evaluates the next message as soon as it exists (i.e. when the bot gets a message from the server)

Slashdot Top Deals

Stellar rays prove fibbing never pays. Embezzlement is another matter.

Working...