Odd word problem: Difference between revisions
m
→{{header|EasyLang}}
(→{{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
end globals
local fn recursion
cfstringref ch = mid(
if fn StringContainsString( @",;:. ", ch ) == no
ndx++
if odd then fn recursion : print ch; ¬
end if
end fn
local fn oddWordTask( s as cfstringref )
ndx = 0 : odd = no :
print : print,
while ndx < len(
fn recursion : print mid(
odd = yes - odd : ndx++
wend
Line 3,016 ⟶ 3,063:
{{trans|Kotlin}}
{{libheader|Wren-str}}
<syntaxhighlight lang="
import "./str" for Char
var fwrite = Fn.new { |ch|
|