3 ms·
The F# version doesn't really implement Amb either. It's similar to the PureBasic and Rust versions in that it can only work on sequences by checking that the l
by rpeden 7y ago
The F# version doesn't really implement Amb either. It's similar to the PureBasic and Rust versions in that it can only work on sequences by checking that the last item in sequence #1 is the same as the first thing in sequence #2.
If I'm reading the page correctly, the task is to create a general Amb implementation and merely demonstrate it using the data provided, and not to create a solution that only works on data similar to the sample data.
So I don't believe any of the PureBasic, Rust, or F# solutions meet the requirements. Though since it's a wiki, someone might have gone in and edited/added to the solutions after I wrote this. :)
In comparison, the class-based C# solutions are a lot more verbose but appear to actually solve the problem that was defined.
- Dylan16807 7y agoThe F# version isn't that limited. You can replace the 'if' with arbitrary logic, and that 'if' is outside of the amb 'implementation'. It can do lots of different computations with that structure. But there's no straightforward way to do things more complicated than a series of amb declarations followed by a series of amb asserts.
- tigershark 7y agoIt’s because you don’t actually need the Amb operator to solve that problem with list comprehension and the list monad. Adding it it’s just superfluous. The C# classes solution may meet the requirements but I still think that my csx solution (kind of similar to the Haskell, F# and python list comprehension) is more compact and readable.