Odd word problem: Difference between revisions

Content added Content deleted
Line 1,498: Line 1,498:
<lang M2000 Interpreter>
<lang M2000 Interpreter>
Module Checkit {
Module Checkit {
global out$
document out$
Function PrepareStream$ (buf$) {
Function PrepareStream$ (buf$) {
\\ get a temporary file
\\ get a temporary file
Line 1,506: Line 1,508:
Close #F
Close #F
Open name$ for input as #f
Open name$ for input as #f
=lambda$ f -> {
class ref {
if f=-1000 then exit
f
class:
module ref (.f) { }
}
\\ make f closure by reference
m->ref(f)
=lambda$ m -> {
if m=>f=-1000 then exit
def r$
def r$
if not eof(#f) then r$=Input$(#f,2)
if not eof(#m=>f) then r$=Input$(#m=>f,2)
=r$
=r$
if r$="" then close #f : f=-1000
if r$="" or r$="." then close #m=>f : m=>f=-1000
}
}
}
}
Line 1,523: Line 1,532:
\\ print before
\\ print before
Print one$;
Print one$;
out$<=one$
Call MyOdd, c$, &last$
Call MyOdd, c$, &last$
}
}
Line 1,532: Line 1,542:
\\ print after
\\ print after
Print one$;
Print one$;
out$<=one$
}
}
Do {
Do {
Line 1,538: Line 1,549:
if one$="" then exit
if one$="" then exit
Print one$;
Print one$;
out$<=one$
one$=""
one$=""
Call MyOdd, c$, &one$
Call MyOdd, c$, &one$
if one$="" then exit
if one$="" then exit
Print one$;
Print one$;
out$<=one$
} Always
} Always
Print
Print
out$<={
}
}
}
Odd PrepareStream$("what,is,the;meaning,of:life.")
Odd PrepareStream$("what,is,the;meaning,of:life.")
Odd PrepareStream$("we,are;not,in,kansas;any,more.")
Odd PrepareStream$("we,are;not,in,kansas;any,more.")
clipboard out$
}
}
Checkit
Checkit