Odd word problem: Difference between revisions

m
(Added FreeBasic)
 
(11 intermediate revisions by 5 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,006 ⟶ 1,055:
Input stream: we,are;not,in,kansas;any,more.
Output stream: we,era;not,ni,kansas;yna,more.</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
begin globals
short ndx : bool odd : cfstringref stream
end globals
 
local fn recursion
cfstringref ch = mid( stream, 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 : stream = s
print : print, stream : print,
while ndx < len( stream )
fn recursion : print mid( stream, ndx, 1 );
odd = yes - odd : ndx++
wend
print
end fn
 
window 1, @"Odd word task in FutureBasic", (0,0,310,155)
fn oddWordTask( @"what,is,the;meaning,of:life." )
fn oddWordTask( @"we,are;not,in,kansas;any,more." )
fn oddWordTask( @"This also works with normal spaces." )
 
HandleEvents
</syntaxhighlight>
{{output}}
[[File:FB output for Odd Word Task.png]]
 
=={{header|Go}}==
Line 2,978 ⟶ 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