POV-Ray : Newsgroups : povray.off-topic : I found this interesting Server Time
4 Jul 2025 10:23:34 EDT (-0400)
  I found this interesting (Message 151 to 154 of 154)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Darren New
Subject: Re: [Caution: long monad ramble]
Date: 13 Apr 2008 22:05:01
Message: <4802bbcd$1@news.povray.org>
Orchid XP v8 wrote:
> There's takeWhile, dropWhile and span which chop up segments of lists. 
> There's "unfoldr" which builds lists. There's "until", which repeats a 
> computation until a condition holds, and returns the final result. And 
> so on...

I think the "until" is what I was after, but the Erlang syntax for 
curried functions is just klunky enough to still make it annoying. 
Still, better than a global name for every while loop. :-)

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

From: Darren New
Subject: Re: [Caution: long monad ramble]
Date: 13 Apr 2008 22:23:46
Message: <4802c032$1@news.povray.org>
Darren New wrote:
> I think the "until" is what I was after, but the Erlang syntax for 
> curried functions is just klunky enough to still make it annoying. 

Ah. Examining unfoldr, I see I was making it too complicated. I was 
trying to figure out how to make "while" (or "until") take two lambdas, 
one for the condition, one for the "body" of the loop. Much easier to 
just have the one function return whether to keep iterating.

Now I can easily say things like "keep prompting and reading a line 
until the user actually types an integer."

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

From: Invisible
Subject: Re: [Caution: long monad ramble]
Date: 14 Apr 2008 05:33:22
Message: <480324e2$1@news.povray.org>
>> foldr is a for-loop, but unfoldr *is* a while-loop, as are the others 
>> I quoted.
> 
> I see the confusion. Erlang isn't lazy.

Laziness for the win! (Or for the user-defined control structures, 
anyway...) :-D

>> Better yet: As far as anybody knows, messages never expire! >:-)
> 
> Immortally famous!

Hell yeah!

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: [Caution: long monad ramble]
Date: 14 Apr 2008 05:34:28
Message: <48032524$1@news.povray.org>
>> I think the "until" is what I was after, but the Erlang syntax for 
>> curried functions is just klunky enough to still make it annoying. 
> 
> Ah. Examining unfoldr, I see I was making it too complicated. I was 
> trying to figure out how to make "while" (or "until") take two lambdas, 
> one for the condition, one for the "body" of the loop. Much easier to 
> just have the one function return whether to keep iterating.
> 
> Now I can easily say things like "keep prompting and reading a line 
> until the user actually types an integer."

Yes indeed. You have found enlightenment...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.