Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
28
Task/Odd-word-problem/Nim/odd-word-problem.nim
Normal file
28
Task/Odd-word-problem/Nim/odd-word-problem.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import os, unicode, future
|
||||
|
||||
proc nothing(): bool{.closure.} = false
|
||||
|
||||
proc odd(prev = nothing): bool =
|
||||
let a = stdin.readChar()
|
||||
if not isAlpha(Rune(ord(a))):
|
||||
discard prev()
|
||||
stdout.write(a)
|
||||
return a != '.'
|
||||
|
||||
# delay action until later, in the shape of a closure
|
||||
proc clos(): bool =
|
||||
stdout.write(a)
|
||||
prev()
|
||||
|
||||
return odd(clos)
|
||||
|
||||
proc even(): bool =
|
||||
while true:
|
||||
let c = stdin.readChar()
|
||||
stdout.write(c)
|
||||
if not isAlpha(Rune(ord(c))):
|
||||
return c != '.'
|
||||
|
||||
var e = false
|
||||
while (if e: odd() else: even()):
|
||||
e = not e
|
||||
Loading…
Add table
Add a link
Reference in a new issue