Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

22
Task/Menu/Nim/menu.nim Normal file
View file

@ -0,0 +1,22 @@
import strutils, rdstdin
proc menu(xs) =
for i,x in xs: echo " ",i,") ",x
proc ok(reply, count): bool =
try:
let n = parseInt(reply)
return 0 <= n and n < count
except: return false
proc selector(xs, prompt): string =
if xs.len == 0: return ""
var reply = "-1"
while not ok(reply, xs.len):
menu(xs)
reply = readLineFromStdin(prompt).strip()
return xs[parseInt(reply)]
const xs = ["fee fie", "huff and puff", "mirror mirror", "tick tock"]
let item = selector(xs, "Which is from the three pigs: ")
echo "You chose: ", item