Created
November 17, 2013 16:18
-
-
Save NN---/7515049 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Nemerle.Collections; | |
using System.Console; | |
module Program | |
{ | |
F(l : list[string], | |
f : string -> list[string]) : list[list[string]] | |
{ | |
def impl(l, acc) | |
{ | |
match(l) | |
{ | |
| [] => [acc] | |
| h :: t => f(h).Map(h' => impl(t, acc + [h'])).Flatten() | |
} | |
} | |
impl(l, []) | |
} | |
Main() : void | |
{ | |
def res = F(["a", "b"], x => [x + "x", x + "y"]); | |
foreach(r in res) | |
WriteLine($"..$r"); | |
_ = ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment