Tested intpl.
h3rald h3rald@h3rald.com
Thu, 22 May 2025 15:56:51 +0200
2 files changed,
18 insertions(+),
7 deletions(-)
M
lib/utils.hex
→
lib/utils.hex
@@ -344,15 +344,19 @@ ;;; intpl
;; s1 q -> s2 ;; Substitutes %:$0%% to %%$9%% placeholders in %:s1%% with items in %:q%%. ( - "_intpl_s" : "_intpl_q" : + "_intpl_s" : 0x0 "_intpl_c" : - (_intpl_c _intpl_s len <) - ( - _intpl_s "$" _intpl_c str cat _intpl_list _intpl_c get cat gsub "_intpl_s" : - _intpl_c 0x1 + "_intpl_c" : - ) - while + (_intpl_q len 0xa >) + ("[symbol intpl] Only a maximum of 10 placeholders are supported" throw) + when + (_intpl_c _intpl_q len <) + ( + _intpl_s "$" _intpl_c str cat _intpl_q _intpl_c get gsub "_intpl_s" : + _intpl_c 0x1 + "_intpl_c" : + ) + while + _intpl_s "_intpl_s" # "_intpl_q" # "_intpl_c" #
M
scripts/test.hex
→
scripts/test.hex
@@ -355,6 +355,13 @@ ((0x1 0x4 0x5) min 0x1 ==)
((0x1 0x4 0x5) max 0x5 ==) ;190 + ("$0, $1!" ("hello" "world") intpl "hello, world!" ==) + (("" ("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n") intpl) (error) try "[symbol intpl] Only a maximum of 10 placeholders are supported" ==) + ("This is a $0, and another $0, and yet another $0" ("test") intpl "This is a test, and another test, and yet another test" ==) + ("$0, $2, $1!" ("first" "third") intpl "first, $2, third!" ==) + ;194 + + ) "TESTS" : ; --- Run Tests