Originally posted by Thue
The problem solved in ML; this solution is nicer.
This is programmed using a very functionel strategy, somewhat different from the PHP one used above. It seemed so much nicer that I tried translating it to php afterwards, but I ended up with a PHP program larger and uglier than the PHP program above.
The problem solved in ML; this solution is nicer.
This is programmed using a very functionel strategy, somewhat different from the PHP one used above. It seemed so much nicer that I tried translating it to php afterwards, but I ended up with a PHP program larger and uglier than the PHP program above.
Code:
val chars = ["a", "b", "c"]; fun gen (a::arest) bs res = (gen (arest@bs) [] (a::res))@(gen arest (a::bs) res) | gen [] [] res = [res] | gen [] bs res = []; gen chars [] [];
Could you please explain the logic to me? I don't get it, not being familiar with ML.
Comment