September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,42 @@
OPEN "/dev/stdin" FOR DEVICE AS in
FUNCTION get_odd()
LOCAL ch, letter
ch = MEMORY(1)
GETBYTE ch FROM in
IF NOT(REGEX(CHR$(PEEK(ch)), "[[:punct:]]")) THEN
letter = get_odd()
PRINT CHR$(PEEK(ch));
ELSE
letter = PEEK(ch)
END IF
FREE ch
RETURN letter
END FUNCTION
mem = MEMORY(1)
PRINT "Enter string: ";
WHILE TRUE
GETBYTE mem FROM in
PRINT CHR$(PEEK(mem));
IF REGEX(CHR$(PEEK(mem)), "[[:punct:]]") THEN
IF PEEK(mem) <> 46 THEN
POKE mem, get_odd()
PRINT CHR$(PEEK(mem));
END IF
IF PEEK(mem) = 46 THEN BREAK
END IF
WEND
FREE mem
CLOSE DEVICE in
PRINT

View file

@ -0,0 +1,31 @@
// version 1.1.3
typealias Func = () -> Unit
fun doChar(odd: Boolean, f: Func?): Boolean {
val c = System.`in`.read()
if (c == -1) return false // end of stream reached
val ch = c.toChar()
fun writeOut() {
print(ch)
if (f != null) f()
}
if (!odd) print(ch)
if (ch.isLetter()) return doChar(odd, ::writeOut)
if (odd) {
if (f != null) f()
print(ch)
}
return ch != '.'
}
fun main(args: Array<String>) {
repeat(2) {
var b = true
while (doChar(!b, null)) b = !b
System.`in`.read() // remove '\n' from buffer
println("\n")
}
}

View file

@ -0,0 +1,33 @@
string s = "what,is,the;meaning,of:life."
--string s = "we,are;not,in,kansas;any,more."
integer i = 0
function getchar()
i += 1
return s[i]
end function
function wrod(integer rev)
integer ch = getchar(), nch
-- integer ch = getc(0), nch
if not find(ch," .,:;!?") then
if rev then
nch = wrod(rev)
end if
puts(1,ch)
if not rev then
nch = wrod(rev)
end if
ch = nch
end if
return ch
end function
--puts(1,"Enter words separated by a single punctuation mark (i.e. !?,.;:) and ending with .\n")
integer rev = 0
while 1 do
integer ch = wrod(rev)
puts(1,ch)
if ch='.' then exit end if
rev = 1-rev
end while

View file

@ -0,0 +1,15 @@
var [const] delim=",:;/?!@#$%^&*()_+", stop=".";
fcn oddly(inStream){
inStream=inStream.walker(3); // character iterator: string, file, etc
doWord:=fcn(inStream,rev,f){ // print next word forewards or reverse
c:=inStream.next();
if(not rev) c.print();
if(not (c==stop or delim.holds(c)))
return(self.fcn(inStream,rev,'{ c.print(); f(); }));
if(rev){ f(); c.print(); }
return(c!=stop);
};
tf:=Walker.cycle(False,True); // every other word printed backwords
while(doWord(inStream, tf.next(), Void)) {}
println();
}

View file

@ -0,0 +1,2 @@
oddly("what,is,the;meaning,of:life.");
oddly(Data(0,String,"we,are;not,in,kansas;any,more."));