Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was looking at something and wasn't sure if I understood it. There's this part of verse:

x:int; y:int; if (x=0) then y=1 else y=2; x=7; y

Ok, so here, y=2. And then it goes on to say that the equal operator within a "conditional scrutinee" is "rigid" and can only be read, not unified. Does that mean if we take out the "x=7;" line, and then evaluate "y", that "y=(2|7)"? Or how exactly does that evaluate?



I would expect "y" to remain unbound, as in "not enough information".

When evaluated, the "if" expression is added to the "knowledge store", so that it will be evaluated when "x" is bound elsewhere, giving "y" the corresponding value (just "1" or just "2", never "(1|2)") only after that.

P.S. See the definition of the "amb" operator in typical logic programming languages:

https://rosettacode.org/wiki/Amb




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: