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,15 @@
// version 1.0.6
val r = Regex("""(/\*.*\*/|//.*$)""")
fun stripComments(s: String) = s.replace(r, "").trim()
fun main(args: Array<String>) {
val strings = arrayOf(
"apples, pears // and bananas",
" apples, pears /* and bananas */",
"/* oranges */ apples // pears and bananas ",
" \toranges /*apples/*, pears*/*/and bananas"
)
for (string in strings) println(stripComments(string))
}

View file

@ -0,0 +1,3 @@
#!/bin/sh
# Strip comments
echo "$1" | sed 's/ *[#;].*$//g' | sed 's/^ *//'

View file

@ -0,0 +1,8 @@
fcn strip(text,c){ // if c in text, remove it and following text
if (Void!=(n:=text.find(c))) text=text[0,n];
text.strip() // remove leading and trailing white space
}
fcn stripper(text,a,b,c,etc){ // strip a,b,c,etc from text
foreach c in (vm.arglist[1,*]){ text=strip(text,c) }
text
}

View file

@ -0,0 +1,6 @@
fcn stripper(text,a,b,c,etc){
vm.arglist[1,*].reduce('wrap(text,c){
if (Void!=(n:=text.find(c))) text[0,n] else text
},text)
.strip()
}

View file

@ -0,0 +1,2 @@
String(">", strip(" apples, pears # and bananas","#"), "<").println();
String(">", stripper(" apples, pears ; and # bananas","#",";"), "<").println();