trim
textSummary
Remove all whitespace from the start and end of text
Description
Whitespace is determined by the whitespace? predicate.
Arguments
text
The input string
Return value
Returns a trimmed version of text
Examples
(trim " Trim Test \n") "Trim Test" (trim " Test\t\n") "Test" (trim "") "" (trim "Test") "Test" (trim "Test ") "Test" (trim " Test") "Test"
Bytecode
Probably only interesting to you if you want to understand more about the Nujel VM or care very much about performance.
( 0 ($push/int/byte 0)) ( 2 ($det/val 'start)) ( 4 ($drop)) ( 5 ($get/val 'buffer/length)) ( 7 ($get/val 'text)) ( 9 ($apply 1)) ( 11 ($det/val 'end)) ( 13 ($drop)) ( 14 ($push/nil)) ( 15 ($jmp* 11)) ( 18 ($drop)) ( 19 ($get/val 'start)) ( 21 ($push/int/byte 1)) ( 23 ($add)) ( 24 ($set/val 'start)) ( 26 ($get/val 'start)) ( 28 ($get/val 'end)) ( 30 ($<)) ( 31 ($dup)) ( 32 ($jf* 16)) ( 35 ($drop)) ( 36 ($get/val 'whitespace?)) ( 38 ($get/val 'buffer/ref)) ( 40 ($get/val 'text)) ( 42 ($get/val 'start)) ( 44 ($apply 2)) ( 46 ($apply 1)) ( 48 ($jt* -30)) ( 51 ($drop)) ( 52 ($push/nil)) ( 53 ($jmp* 11)) ( 56 ($drop)) ( 57 ($get/val 'end)) ( 59 ($push/int/byte 1)) ( 61 ($sub)) ( 62 ($set/val 'end)) ( 64 ($get/val 'end)) ( 66 ($push/int/byte 0)) ( 68 ($>)) ( 69 ($dup)) ( 70 ($jf* 19)) ( 73 ($drop)) ( 74 ($get/val 'whitespace?)) ( 76 ($get/val 'buffer/ref)) ( 78 ($get/val 'text)) ( 80 ($get/val 'end)) ( 82 ($push/int/byte 1)) ( 84 ($sub)) ( 85 ($apply 2)) ( 87 ($apply 1)) ( 89 ($jt* -33)) ( 92 ($drop)) ( 93 ($get/val 'string/cut)) ( 95 ($get/val 'text)) ( 97 ($get/val 'start)) ( 99 ($get/val 'end)) ( 101 ($apply 3)) ( 103 ($ret))