Odd word problem: Difference between revisions

Add Julia language
(Add Julia language)
Line 1,346:
}</lang>
Output is equivalent to that of the Python solution.
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
{{trans|Python}}
<lang julia># io = readstring(STDIN)
io = "what,is,the;meaning,of:life."
i = 0
 
readbyte!() = io[global i += 1]
writebyte(c) = print(Char(c))
 
function odd(prev::Function = () -> false)
a = readbyte!()
if !isalpha(a)
prev()
writebyte(a)
return a != '.'
end
 
# delay action until later, in the shape of a closure
clos() = (writebyte(a); prev())
 
return odd(clos)
end
 
function even()
while true
c = readbyte!()
writebyte(c)
if !isalpha(c) return c != '.' end
end
end
 
evn = false
while evn ? odd() : even()
evn = !evn
end</lang>
 
{{out}}
<pre>what,si,the;gninaem,of:efil.</pre>
 
=={{header|Kotlin}}==
Anonymous user