all repos — hex @ 608b4c9d5a74f2ab3328156c13547049d939c485

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Implemented intpl
h3rald h3rald@h3rald.com
Sun, 22 Dec 2024 20:45:58 +0100
commit

608b4c9d5a74f2ab3328156c13547049d939c485

parent

ebb8b5ee51af610882bd13e3ce90dd68e404c6f5

1 files changed, 25 insertions(+), 3 deletions(-)

jump to
M lib/utils.hexlib/utils.hex

@@ -270,7 +270,26 @@ ) "max" ::

;;; intpl ;; s1 q -> s2 -;; Substitutes %%%#%% placeholders in %%s1%% with items in %%q%%. +;; Substitutes %%$0%% to %%$9%% placeholders in %%s1%% with items in %%q%%. +( + "_s" : + "_q" : + (_s iss _q isq and not) + ("[symbol intpl] String and quotation required" fail) + when + _q len "_len" : + 0x0 "_c" : + (_c len <) + ( + _s "$" _c str cat _list _c get cat replace-all "_s" : + _c 0x1 + "_c" : + ) + while + "_s" # + "_q" # + "_c" # + "_len" # +) "intpl" :: ;;; each ;; q1 q2 -> *

@@ -278,13 +297,16 @@ ;; Applies %%q2%% to each element of %%q1%%.

( "_fn" : "_list" : - (_fn isq _list isq and) + (_fn isq _list isq and not) ("[symbol each] Two quotations required" fail) when _list len "_len" : 0x0 "_c" : (_c len <) - (_list _c get _fn .) + ( + _list _c get _fn . + _c 0x1 + "_c" : + ) while "_fn" # "_list" #