March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,21 @@
( " apples, pears # and bananas
oranges, mangos ; and a durian"
: ?text
& :?newText
& ( non-blank
= %@:~(" "|\t|\r|\n)
)
& ( cleanUp
=
. @(!arg:?arg ("#"|";") ?)
& @(rev$!arg:? (!non-blank ?:?arg))
& @(rev$!arg:? (!non-blank ?:?arg))
& !arg {You could write & "[" !arg "]" to prove that the blanks are stripped.}
)
& whl
' ( @(!text:?line (\r|\n) ?text)
& !newText \n cleanUp$!line:?newText
)
& !newText \n cleanUp$!text:?newText
& out$(str$!newText)
);

View file

@ -0,0 +1,6 @@
(defun strip-comments (s cs)
"Truncate s at the first occurrence of a character in cs."
(defun comment-char-p (c)
(some #'(lambda (x) (char= x c)) cs))
(let ((pos (position-if #'comment-char-p s)))
(subseq s 0 pos)))

View file

@ -1 +1 @@
strip=: #~ *./\@:-.@e.&';#'
strip=: dltb@(#~ *./\@:-.@e.&';#')

View file

@ -1 +1 @@
strip=: {.~ <./@i.&';#'
strip=: dltb@({.~ <./@i.&';#')

View file

@ -1,4 +1,4 @@
strip 'apples, pears # and bananas'
apples, pears
strip 'apples, pears ; and bananas'
apples, pears
dquote strip ' apples, pears # and bananas' NB. quote result to show stripped whitespace
"apples, pears"
strip ' apples, pears ; and bananas'
"apples, pears"