View Problem

Separate user interaction and computation.

Allow your program to accept user interaction while conducting a long running computation.

Example:

Hello user! Please input a string to permute: (input thread)
abcdef
Passing on abcdef... (input thread)
Please input another string to permute: (input thread)
lol
Passing on lol... (input thread)
Done Work On abcdef! (worker thread)
["abcdef", "abcefd", ... ] (worker thread)
Please input another string to permute: (input thread)
EXIT
Quitting, I'll let my worker thread know... (input thread)
We'
re quitting! Alright! (worker thread)

--Notice, that this could be accomplished on the command line or within a GUI. The point is that computation and user interaction should take place on separate threads of control.
DiskEdit
fantom
using concurrent
class Main
{
static Void main()
{
worker := Actor(ActorPool()) |Str s|
{
result := permute(s.chars).map { Str.fromChars(it) }
echo("Done Work On $s!")
echo(result)
}

Env.cur.out.writeChars("Hello, user! Please input a string to permute: ").flush
Env.cur.in.eachLine |line| {
echo("Passing on $line ...")
worker.send(line)
Env.cur.out.writeChars("Please input another string to permute: ").flush
}
}

static Obj[][] permute(Obj[] list, Obj[] prefix := [,])
{
list.isEmpty ?
[prefix] :
list.reduce([,]) |Obj[] r, Obj item, Int i -> Obj[]| {
r.addAll(permute(list.dup { removeAt(i) }, prefix.dup.add(item)))
}
}
}

Submit a new solution for fantom
There are 7 other solutions in additional languages (clojure, cpp, fsharp, groovy ...)