Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - rrq

#1
newLISP newS / Re: Wisp to new lisp
June 13, 2025, 09:11:43 PM
Yes I like parentheses too 8) . I remember Interlisp having square brackets as "meta parentheses" so as to avoid strings of stopping parentheses; the two forms interoperated so that ']' closed all '(' to match prior balancing '[', and likewise ')' closed all '[' to match prior balancing '('.
One could then write for example the following
(define (factorial n)
    [if (zero? n)
        1
        (* n (factorial (- n 1 ] )
Perhaps it's clearer? But the reader has to know the syntax in any case.
#2
newLISP in the real world / Re: regex-all
June 13, 2025, 06:53:48 PM
I suppose one might use find-all for that. Though, find-all doesn't provide the character index, and it doesn't provide the match overlap variant. It wouldn't be terribly hard to patch the source to make find-all offer the index (eg as $index) similar to the match count.

However, one can use collect and a small helper function to get the following alternative solution:
> (define (regex-all EXP STR OPT ALL)
  (let ((i 0)
     (move-i (fn (X) (setq i (+ (X 1) (if ALL 1 (X -1)))) X)))
      (collect (if (regex EXP STR OPT i) (move-i $it)))))

> (setq a "AAAaBAAAABcADccAAAB")
> (regex-all "[A]{3}" a 0)
(("AAA" 0 3) ("AAA" 5 3) ("AAA" 15 3))
> (regex-all "[A]{3}" a 0 true)
(("AAA" 0 3) ("AAA" 5 3) ("AAA" 6 3) ("AAA" 15 3))

EDIT: I fixed to use EXP rather than hard-coded search pattern.
#3
At a guess libm is missing in the chroot. Check library dependencies with ldd.
#4
The steps I take are basically to
1. first create the makefile_build the normal way and then
2. copy that to a makefile_static file which I hand-edit:
3. remove -DFFI -DREADLINE (see below) from the CFLAGS setup
4. change the "default:" target action to be the two steps
  $(CC) $(OBJS) -m64 -o newlisp -static -Wl,-Bstatic -lm -lc
  strip newlisp

That's with gcc on a linux amd64 (devuan). I've got libc.a and libm.a from the libc6-dev package, and I don't include the FFI and READLINE options for it. Thoug I think you can find .a libraries for them too (libreadline-dev and libffi-dev packages)

EDIT: digging up that old project, I realized it needed musl-gcc as well; gcc doesn't seem to be capable of static binaries.

EDIT: maybe I confused myself; it seems gcc does it well too, and then you may also include ffi and readline (+termcap).
#5
newLISP in the real world / Re: replace help
November 13, 2024, 04:38:35 PM
Yes it can be a bit confusing. The string returned by replace does have single-quotes replaced by double-quotes, but the interactive result output presents the double-quotes prefixed by backslash.

Thus, when the string has a double quote, the result printing of that string shows \" so as to indicated that the double-quote is not ending the string. Likewise, the result printing adds the double-quotes before and after printing the string content, and those double-quotes are not characters in the string.

If you make it be
(print (replace ....))then the string will be printed without extras before double-quotes, but the interactive output coming after will still show the string with that meta-character wrapping.

In short, a string of a single double-quote characters is written "\"", and it will be taken as such if input and printed as such by the interactive output. The print function doesn't add meta-characters. Here's an illustration example:
> (println "\"")
"
"\""
>
The first line is what the println function prints (which is the "raw" string content with a newline added at end), and the second line is the interactive output of the value returned by the println function (the same string but with meta-characters to make it be the character sequence the input reader would need).
#6
Fun :)

May I also suggest that you lift out the command key dispatch as a key-action association list between key and action. Eg

(setf ACTIONS '(
    (87 up)    (119 up)
    (65 left)  (97  left)
    (85 down)  (115 down)
    (68 right) (100 right)
    (48 exit) ; "0" --> quit the game
))

The "case" statement would be replaced by something like the following "if" statement:

(if (lookup (setf key (read-key)) ACTIONS) (apply $it)
    (println "Wrong key.") (setq key-error true))

That would open it up slightly for easier change of command keys.
#7
newLISP in the real world / Re: replace help
November 12, 2024, 04:35:25 PM
So 'a gets set to a list of a string ? Did you mean to set it to the string rather? like
(set 'a "{'symbol': 'BURT/USDT', ... 'markPrice': None}")
#8
newLISP in the real world / Re: hmac signatures
October 26, 2024, 01:30:46 PM
Wouldn't you need to use crypto:hmac ?
#9
newLISP in the real world / Re: A simple(?) problem
June 26, 2024, 02:08:55 PM
Yeah. Way faster than mine :)

chhers
#10
newLISP in the real world / Re: A simple(?) problem
June 25, 2024, 05:37:41 AM
This one is straight-forward but probably a bit slow
(define    (randint RANGE DIGITS)
  (letn ((digits (fn (X) (map int (unique (explode (string X))))))
         (wrong (fn (X) (difference (digits X) DIGITS)))
         (S (clean wrong (apply sequence RANGE))))
    (S (rand (length S)))))

EDIT: simplify by using "apply"

EDIT 2: recusive digitization might be faster (?)
EDIT 3: changed back to use stringifying; looks nicer :)
#11
newLISP newS / Re: sending emails to @gmail.com
May 23, 2023, 01:23:05 PM
Au contraire ;D I, at gmail.com, got the notification email from this forum today. Which is great. Something got improved ...
#12
Thanks @itistoday!! Great to be at a new forum home.

Here's a pointer to a few of my newlisp projects

Most of them are functional, but generally they are for fun.
#13
newLISP newS / Re: sending emails to @gmail.com
May 22, 2023, 05:04:52 PM
Eh? Doesn't your ISP provide rDNS setup?

EDIT: it's not related to email as such, and I agree that setting up your own MTA would be too much.

EDIT 2: not sure if relevant:
https://clientarea.ramnode.com/knowledgebase/19/How-do-I-set-reverse-DNS-RDNSorPTR.html
#14
newLISP newS / Re: sending emails to @gmail.com
May 22, 2023, 04:54:09 PM
Well, I'm not trying to support any of Google's business practices; just trying to assist in getting the forum emails delivered to @gmail.com addresses (especially since I happen to have one).

And for that I believe it would be good getting the rDNS sorted for newlispfanclub.com.
#15
newLISP newS / Re: sending emails to @gmail.com
May 22, 2023, 03:59:37 PM
Yes, the MTA setup would be fine, but afaik gmail will want the original sender (newlispfanclub.com) to have rDNS set up (as well), especially for resolvable hosts "without history".