Skip to content

Instantly share code, notes, and snippets.

@NN---
Created November 17, 2013 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NN---/7515049 to your computer and use it in GitHub Desktop.
Save NN---/7515049 to your computer and use it in GitHub Desktop.
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