Odd word problem: Difference between revisions

Content added Content deleted
(→‎{{header|PL/I}}: Remove bogus "incorrect" markup. The task requirement _specifically_ allows recursion. (Bullet point 3))
(Added Wren)
Line 2,771: Line 2,771:
First way : what,si,the;gninaem,of:efil.
First way : what,si,the;gninaem,of:efil.
Second way : what,si,the;gninaem,of:efil.</pre>
Second way : what,si,the;gninaem,of:efil.</pre>

=={{header|Wren}}==
{{trans|Kotlin}}
{{libheader|Wren-str}}
<lang ecmascript>import "io" for Stdin,Stdout
import "/str" for Char

var fwrite = Fn.new { |ch|
System.write(ch)
Stdout.flush()
}

var doChar // recursive
doChar = Fn.new { |odd, f|
var c = Stdin.readByte()
if (!c) return false // end of stream reached
var ch = String.fromByte(c)

var writeOut = Fn.new {
fwrite.call(ch)
if (f) f.call()
}

if (!odd) fwrite.call(ch)
if (Char.isLetter(ch)) return doChar.call(odd, writeOut)
if (odd) {
if (f) f.call()
fwrite.call(ch)
}
return ch != "."
}

for (i in 0..1) {
var b = true
while (doChar.call(!b, null)) b = !b
Stdin.readByte() // remove \n from buffer
System.print("\n")
}</lang>

{{out}}
<pre>
what,is,the;meaning,of,life.
what,si,the;gninaem,of,efil.

we,are;not,in,kansas;any,more.
we,era;not,ni,kansas;yna,more.

</pre>


=={{header|zkl}}==
=={{header|zkl}}==