Search found 228 matches

by ralph.ronnquist
Sun Dec 02, 2018 10:23 am
Forum: newLISP in the real world
Topic: Cmdline-option to keep newlisp instance running
Replies: 3
Views: 2956

Re: Cmdline-option to keep newlisp instance running

Isn't that kind of what -d offers?
Though you'd connect to it with, say, telnet or netcat (or whatever it's called on Windows).
by ralph.ronnquist
Thu Nov 29, 2018 2:06 am
Forum: newLISP in the real world
Topic: factor-group function
Replies: 3
Views: 3771

Re: factor-group function

Nice. The factorization is of course the "slow" part, whereas the result juggling is almost irrelevant time-wise. I wouldn't try to improve on your implementation, but as a hind-sight, I probably would have used (map list unici (count unici fattori)) instead of (transpose (list unici (count unici fa...
by ralph.ronnquist
Sun Jul 15, 2018 12:07 am
Forum: newLISP in the real world
Topic: Why the fexpr's internal variable's name couldn't be same as
Replies: 2
Views: 3057

Re: Why the fexpr's internal variable's name couldn't be sam

Isn't it just a normal effect of dynamic binding; that any assignment always affects the "inner-most" variable of the name. It's not special to fexprs, but you can confuse yourself quite easily with "normal" lambdas if/when a lambda body refers to a variable outside its scope. For example, if you ha...
by ralph.ronnquist
Thu Jul 12, 2018 1:25 pm
Forum: newLISP in the real world
Topic: Sorting a list or string
Replies: 4
Views: 4289

Re: Sorting a list or string

You might have meant the third line be

Code: Select all

(set 'worder (map lower-case words))
by ralph.ronnquist
Thu Jun 28, 2018 10:53 pm
Forum: newLISP in the real world
Topic: How to get return value of every spawn process iteration
Replies: 2
Views: 3444

Re: How to get return value of every spawn process iteration

You could do something like this (dotimes (i cpu-num) (spawn (last (push (sym (string "ret" i)) returns -1)) (println i))) That'd make returns be a list of the return symbols, letting you do (eval (returns k)) to obtain the return value of the k:th sub process. Or, you may want an association list, ...
by ralph.ronnquist
Thu Feb 01, 2018 3:38 am
Forum: newLISP in the real world
Topic: httpd-conf intercept requests and answer with a function?
Replies: 6
Views: 5886

Re: httpd-conf intercept requests and answer with a function

For small scale http services I typically use thttpd as frontend, with newlisp for the "cgi" scripting. Quick and easy :)
by ralph.ronnquist
Sun Nov 19, 2017 8:21 am
Forum: newLISP in the real world
Topic: parameter for http only
Replies: 6
Views: 5554

Re: parameter for http only

You might want to check out thttpd,
by ralph.ronnquist
Sat Nov 11, 2017 1:02 am
Forum: newLISP in the real world
Topic: It makes me a bit confused
Replies: 1
Views: 2594

Re: It makes me a bit confused

I'm not sure which part is confusing for you. I think the story would be something like the following: A char* is a pointer to a char, and not the array of char that it points to. Thus, with (pack A "HELLO") a char* record created with a pointer that points to the temporarily allocated char array "H...
by ralph.ronnquist
Mon Oct 30, 2017 4:59 am
Forum: newLISP in the real world
Topic: csv to nested list?
Replies: 1
Views: 3104

Re: csv to nested list?

Doing it properly might require a proper CSV parser, like https://github.com/kanendosei/artful-newlisp/blob/master/csv.lsp I must admit I haven't tried it myself, but it looks fine at a glance. Load that file, then it's simply a matter of (CSV:parse-file csvfile) if you're using comma as delimiter a...
by ralph.ronnquist
Wed Sep 13, 2017 9:24 am
Forum: newLISP in the real world
Topic: Why is the behavior of "trim" function so strange?
Replies: 11
Views: 8664

Re: Why is the behavior of "trim" function so strange?

Technically, since neither "\xbb\xe1" nor "\xce\xaa\xca\xb2\xc3\xb4\xbb\xe1" are valid UTF-8 strings, the trim behaviour is conveniently undefined. It appears the trim function expands "\xbb" into a 2-byte code, and "\xe1" into a three byte code, making its output valid UTF-8. ("\xce\xaa", "\xca\xb2...
by ralph.ronnquist
Mon Sep 11, 2017 2:01 am
Forum: newLISP in the real world
Topic: Get line number of script line currently executed
Replies: 1
Views: 2590

Re: Get line number of script line currently executed

If nothing else, you could perhaps use an expression reading counter

Code: Select all

(reader-event (fn (x) (inc $exprno) x))
by ralph.ronnquist
Thu Aug 24, 2017 6:33 am
Forum: newLISP in the real world
Topic: dolist on main-args problem
Replies: 6
Views: 5336

Re: dolist on main-args problem

Well, that's a repetition over the command line arguments, starting with the third. Specifically: + when invoked without arguments, the main-args function returns the command line arguments as a list of strings. When invoked with an argument, an integer, then it returns only that command line argume...
by ralph.ronnquist
Thu Aug 24, 2017 4:00 am
Forum: newLISP in the real world
Topic: dolist on main-args problem
Replies: 6
Views: 5336

Re: dolist on main-args problem

One could read it like this: that the first element of a dolist is a list with three elements: - firstly a symbol, - then a list or array, - then, optionally, a "break expression". Especially, that break expression is a third element of the list, and not an argument to the list construction expressi...
by ralph.ronnquist
Wed Aug 23, 2017 10:51 pm
Forum: newLISP in the real world
Topic: dolist on main-args problem
Replies: 6
Views: 5336

Re: dolist on main-args problem

Maybe you confuse it with the following?

Code: Select all

(dolist (x (2 (main-args)))
by ralph.ronnquist
Tue Aug 22, 2017 4:03 am
Forum: newLISP in the real world
Topic: set - setf - setq woes
Replies: 6
Views: 5324

Re: set - setf - setq woes

Hmm, did you have the variable quoted maybe?
by ralph.ronnquist
Fri Aug 18, 2017 10:38 pm
Forum: newLISP in the real world
Topic: Setting up hash items at once
Replies: 2
Views: 3064

Re: Setting up hash items at once

And you can of course combine it into a single phrase like

Code: Select all

((or (define cities:cities) cities)
  '(("ny" "new york")  ("sf" "san francisco")))
but it's not very intelligible.
by ralph.ronnquist
Wed Jul 19, 2017 11:04 am
Forum: Anything else we might add?
Topic: about (directory)
Replies: 11
Views: 9270

Re: about (directory)

Hmm, I get the following > (length "新建文本文档") 18 > (unpack (dup "b" 18) "新建文本文档") (230 150 176 229 187 186 230 150 135 230 156 172 230 150 135 230 161 163) I.e., my byte sequence for the first string (copy-and-paste from this forum) is the same as your byte sequence for the second string. > (length "...
by ralph.ronnquist
Tue Jul 11, 2017 9:46 pm
Forum: Anything else we might add?
Topic: shell-like scripting
Replies: 4
Views: 4745

Re: shell-like scripting

The ! function waits for the command to complete, so without the outer fork , only one sub process at a time would be performed. You could redesign it to use process , which includes its own fork+exec , to avoid the explicit outer fork (and the first explicit right-shifting); maybe that'd be more su...
by ralph.ronnquist
Tue Jul 11, 2017 1:19 pm
Forum: Anything else we might add?
Topic: shell-like scripting
Replies: 4
Views: 4745

Re: shell-like scripting

As you know, one way to pass command return code is via ! and wait-pid , the former captures the return code of the invoked shell command, and the latter of a child (though the function return values need downshifting 8 bits to be the actual return code). I made the following toy example to experime...
by ralph.ronnquist
Wed Jul 05, 2017 10:41 pm
Forum: Anything else we might add?
Topic: Error in gsl.lsp ?
Replies: 3
Views: 4746

Re: Error in gsl.lsp ?

#(MAIN:gsl_matrix_set MAIN:Aptr MAIN:i MAIN:j 0 MAIN:.0)#))
Apparently the input "0.0" gets broken up into the two tokens "0" and ".0" with the latter being a symbol when the module is loaded. Odd.
by ralph.ronnquist
Thu Jun 29, 2017 9:18 am
Forum: newLISP in the real world
Topic: multiple-value-bind
Replies: 3
Views: 3508

Re: multiple-value-bind

mmm, you might have meant something like this? macro (mvb) nil) (constant 'mvb (lambda-macro () (extend (list 'let (map list (args 0) (args 1))) (2 (args))))) I.e., create a let clause with the two first arguments as variable assignments, then the rest forming the body. It breaks violently on bad sy...
by ralph.ronnquist
Tue Jun 27, 2017 2:26 pm
Forum: newLISP in the real world
Topic: Infix.lsp as macro
Replies: 4
Views: 3979

Re: Infix.lsp as macro

Well, being or not being a macro is, I believe, some flag attached to the symbol, which is set by the "(macro ..)" term. That term also wraps the given "body" into an "expand" term, as is typically useful for these kinds of macros. But not in this case, where you want the xlate-ion to be invoked at ...
by ralph.ronnquist
Tue Jun 27, 2017 12:45 pm
Forum: newLISP in the real world
Topic: Infix.lsp as macro
Replies: 4
Views: 3979

Re: Infix.lsp as macro

You may do this kind of thing in two steps. Firstly, you define a macro, e.g. > (macro (mix) nil) (lambda-macro () (expand 'nil)) Thereafter you redefine it to perform the "xlate" call the way you want it, e.g. > (constant 'mix (lambda-macro () (INFIX:xlate (join (map string (args)) " ")))) (lambda-...
by ralph.ronnquist
Fri Jan 27, 2017 9:26 pm
Forum: newLISP in the real world
Topic: regex doesn't match utf-8 character using \w pattern
Replies: 2
Views: 2940

Re: regex doesn't match utf-8 character using \w pattern

I believe the magic of regex is explained in http://www.newlisp.org/downloads/pcrepattern.html , where you find the two paragraphs: ------ A "word" character is an underscore or any character less than 256 that is a letter or digit. The definition of letters and digits is controlled by PCRE's low-va...
by ralph.ronnquist
Wed Dec 21, 2016 9:10 pm
Forum: newLISP in the real world
Topic: generating aws signature
Replies: 13
Views: 9545

Re: generating aws signature

An online tool, using a form, would typically digest line ends as \r\j, whereas a *nix system would prefer using \j only, and a mac system would rather favour \r for line endings. The AWS tool you pointed at some posts earlier appears to compute the signature using \j line endings. And it also scram...