All pastes #400186 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-18 15:30 UTC
rendered paste body
alias f {
unset %z
set %y $replace($1-,$chr(32),$chr(134)) 
var %x $len(%y)
while (%x > 0) {
set -u1 %z $+(%z,$mid(%y,%x,1))
dec %x
}
unset %y
return $replace(%z,$chr(134),$chr(32))
}
alias btok {
unset %c
unset %q
unset %p
if ($gettok($1-,-1,32) == 44) || ($v1 !isnum) { return Err }
else {
set -u1 %q $gettok($1-,1- $+ $calc($gettok($1-,0,32) - 1),32)
set -u1 %p $gettok($1-,-1,32)
if (%p != $null) {
var %x 1
while ($gettok(%q,%x,%p)) {
var %b $v1
if (. isin $calc(%x / 2)) {
set -u1 %c %c $+ %b
}
else {
set -u1 %c %c $+ $f(%b)
}
inc %x
}
}
return %c
}
}