Odd word problem: Difference between revisions

m
(→‎{{header|FutureBasic}}: Replaced with new code that more closely follows task guidelines, using a recursive function.)
 
(4 intermediate revisions by 3 users not shown)
Line 675:
readln;
end.</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight>
global inpi inp$ .
func$ read .
inpi += 1
return substr inp$ inpi 1
.
func ispunct c$ .
if c$ = "." or c$ = ":" or c$ = ";" or c$ = ","
return 1
.
return 0
.
func$ handle odd .
c$ = read
if ispunct c$ = 1
return c$
.
if odd = 0
write c$
r$ = handle 0
return r$
else
r$ = handle 1
write c$
return r$
.
.
proc go . .
repeat
c$ = handle odd
write c$
until c$ = "."
odd = 1 - odd
.
print ""
.
repeat
inp$ = input
until inp$ = ""
inpi = 0
go
.
input_data
we,are;not,in,kansas;any,more.
what,is,the;meaning,of:life.
 
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 1,010 ⟶ 1,059:
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
 
begin globals
short ndx : bool odd : cfstringref sequencestream
end globals
 
local fn recursion
cfstringref ch = mid( sequencestream, ndx, 1 )
if fn StringContainsString( @",;:. ", ch ) == no
ndx++
if odd then fn recursion : print ch; ¬
else print ch; : fn recursion
end if
end fn
 
local fn oddWordTask( s as cfstringref )
ndx = 0 : odd = no : sequencestream = s
print : print,sequence stream : print,
while ndx < len( sequencestream )
fn recursion : print mid( sequencestream, ndx, 1 );
odd = yes - odd : ndx++
wend
Line 3,016 ⟶ 3,063:
{{trans|Kotlin}}
{{libheader|Wren-str}}
<syntaxhighlight lang="ecmascriptwren">import "io" for Stdin,Stdout
import "./str" for Char
 
var fwrite = Fn.new { |ch|
2,060

edits