From d7f41dca3b24bccb4bf3560fa88a19c4229e68d8 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 7 Apr 2024 11:22:18 -0700 Subject: [PATCH] Unwrapped explode --- examples/test.modal | 6 ++---- src/modal.c | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/test.modal b/examples/test.modal index 2b3e220..304459e 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,5 +1,3 @@ -<> (?x dup) (?x ?x) -<> (?x ?y swap) (?y ?x) -<> ( ?x pop) () +<> ((explode ?*)) (?*) -(1 2 3) (4 5 6) swap pop dup +(explode hello) \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index e188595..68c4366 100644 --- a/src/modal.c +++ b/src/modal.c @@ -89,8 +89,12 @@ plode(char *s) if(!depth) return s; } } else { /* explode */ - while((c = *s++) && !spacer(c)) + *outp_++ = *s++, *outp_++ = ' '; + while((c = *s++) && !spacer(c)) { *outp_++ = '(', *outp_++ = c, depth++; + if(!spacer(*s)) + *outp_++ = ' '; + } for(i = 0; i < depth; i++) *outp_++ = ')'; }