On 12 Mai, 02:10, Tomasz Rola <rto...@ceti.com.pl> wrote: > On Mon, 11 May 2009, rump...@web.de wrote: > > > One question I ask myself upon seeing a new language is if it is possible > > > to program amb (amb=ambiguous) operator in it. This page gives a very > > > nice, "code first" explanation of amb and how it is supposed to work: > > > >http://www.randomhacks.net/articles/2005/10/11/amb-operator > > > Hm. I am not sure either. To me, it looks like a constraint solver by > > using brute force. > > Yes, kind of. From what I understand [1], it's goal is to simulate > nondeterministic "get right answer in one try", only this "one try" > requires browsing the solution space (because we have only "classic" > hardware). It is easy to use amb in wrong way, but I can see some cases > when I would like it.
In Python you can use a generator expression. Dan Piponis example can be stated as g = ((i,j) for i in range(2,100) for j in range(2,i) if i*j == 481) which doesn't require any call/cc hacks but is a deterministic "get right in one try". Once Nimrod has coroutines it's just a matter of sugaring them into comprehensions. > > [1] John McCarthy's paper still waits to be read by me, so... Ok, I have > just had a look at it and it seems that Ruby implementation is a bit > primitive compared to original concept. But still, this is what would be > needed in most real life cases, I suppose. > > I think ability to define amb would allow me to write more concise code. > As far as I can tell, this kind of stuff plays more and more important > role in my programing. > > > It seems to require continuations. AFAIK > > continuations are extremely hard to implement efficiently, so probably > > it won't be done in Nimrod. > > Pity, a little. But not really big problem for me. Nimrod may be > interesting anyway, time will tell :-). > > Regards, > Tomasz Rola > > -- > ** A C programmer asked whether computer had Buddha's nature. ** > ** As the answer, master did "rm -rif" on the programmer's home ** > ** directory. And then the C programmer became enlightened... ** > ** ** > ** Tomasz Rola mailto:tomasz_r...@bigfoot.com ** -- http://mail.python.org/mailman/listinfo/python-list