Search found 228 matches

by ralph.ronnquist
Tue Aug 06, 2019 11:21 am
Forum: newLISP in the real world
Topic: Web app server
Replies: 3
Views: 3471

Re: Web app server

Can newLISP be used to create a standalone http web app server? The answer to that one is of course "yes"; newlisp, with -http, provides a basic HTTP server for a small range of file types, including ".cgi" which it handles in a similar way to apache2. I.e., the ".cgi" file is an executable, and po...
by ralph.ronnquist
Sat Jun 22, 2019 2:22 am
Forum: newLISP and the O.S.
Topic: Compile script to .exe with attached files
Replies: 8
Views: 9519

Re: Compile script to .exe with attached files

Well, as always, the first thing to exclude is "operator error". I don't know what the prevalent mistakes might be for Windows, but at least you should confirm that the program runs without being packed into a single executable. I.e., if the program is in the scripts A.lsp , B.lsp and C.lsp , with A...
by ralph.ronnquist
Mon Jun 17, 2019 9:49 pm
Forum: newLISP in the real world
Topic: loading html templates
Replies: 2
Views: 3153

Re: loading html templates

If that printing happens from a CGI script for newlisp in -html operation, then it'd be explained as an API misunderstanding. newlisp in -html mode is quite forgiving about the CGI response, but it treats anything before the first empty line as the HTTP headers part, and that following the first emp...
by ralph.ronnquist
Mon Jun 17, 2019 1:20 pm
Forum: newLISP in the real world
Topic: initializer expressions by a predefined list in "let"
Replies: 3
Views: 3578

Re: initializer expressions by a predefined list in "let"

The use of single symbol is not a documented syntax form , and generally, that second element of the let term is not evaluated but processed as is (and only evaluated in parts). So that syntax form is a DIY opportunity :) For a once-off need, I'd wrap it into a letex , as in the following. (letex (l...
by ralph.ronnquist
Sat Jun 15, 2019 11:56 pm
Forum: newLISP in the real world
Topic: format json-parse data into html
Replies: 7
Views: 5882

Re: format json-parse data into html

If you read first argument to format very carefully a few times, you will eventually discover the missing back-quote. :)
by ralph.ronnquist
Sat Jun 15, 2019 12:56 am
Forum: newLISP in the real world
Topic: format json-parse data into html
Replies: 7
Views: 5882

Re: format json-parse data into html

Yes, I kind of thought that jsondata was the whole thing. Since you have (set 'jsondata (lookup "products" (lookup "result" alie))) it'll already have gone into the "products" value part, and therefore my suggested ref of a ("product" ?) pair in jsondata isn't much good. As you noticed :) If jsondat...
by ralph.ronnquist
Mon Jun 10, 2019 7:07 am
Forum: newLISP in the real world
Topic: format json-parse data into html
Replies: 7
Views: 5882

Re: format json-parse data into html

You may want to build around using ref and ref-all , to "pick raisins"; something like this perhaps: (define (raisins jsonitem) (format "<a href=\"%s\">%s</a>\n"<img src=\"%s\">\n\n" (string (if (ref '("productUrl" ?) jsonitem match true) ($it 1))) (string (if (ref '("imageTitle" ?) jsonitem match t...
by ralph.ronnquist
Wed Jun 05, 2019 12:43 pm
Forum: newLISP in the real world
Topic: Primitive "case" does not work
Replies: 3
Views: 3451

Re: Primitive "case" does not work

I suppose it links back to how the case term works in other Lisp variations.

There are also other conditional term forms such as if and cond to fill the need. Perhaps the prior question would be to ponder why having a case term at all.
by ralph.ronnquist
Wed Jun 05, 2019 9:37 am
Forum: newLISP in the real world
Topic: Primitive "case" does not work
Replies: 3
Views: 3451

Re: Primitive "case" does not work

Yes, as you know, the case term does not evaluate the branch keys, so you'll have to resort to a letex embedding, as in

Code: Select all

(define (f obj a da b db)
  (letex ((a a) (b b))
      (case obj
          (a da)
          (b db)
          (true obj)
   )))
by ralph.ronnquist
Fri May 31, 2019 2:55 am
Forum: newLISP in the real world
Topic: Maximum Product Sublist
Replies: 5
Views: 4238

Re: Maximum Product Sublist

Indeed, sublist was a quite fun exercise. Thanks :) I ended up with the following as my "best" candidate: (define (sublists s (i 0) (n (inc (length s))) (N n)) (collect (if (> n 2) (i (dec n) s) (> (setf n (dec N)) 2) ((inc i) (dec n) s)))) That one performed best for me, and (more or less incidenta...
by ralph.ronnquist
Thu May 30, 2019 11:29 am
Forum: newLISP in the real world
Topic: Group the elements of a list
Replies: 10
Views: 6454

Re: Group the elements of a list

Thanks. Yes, as you say, the trans function really treats its input list s as a collection of equivalence classes, and combines those that overlap into the smallest collection of classes. The similar function for non-reflexive relations (or directed arcs) would rather concern transitive reachability...
by ralph.ronnquist
Wed May 29, 2019 8:51 am
Forum: newLISP in the real world
Topic: Group the elements of a list
Replies: 10
Views: 6454

Re: Group the elements of a list

How about "transitive closure", then? I.e. given a list of pairs that notionally would, say, represent links in a graph, determine the lists of transitively connected "nodes", or in other words, join all sub-lists that share some element (transitively). A recursive solution could be something like t...
by ralph.ronnquist
Mon May 13, 2019 7:51 am
Forum: newLISP and the O.S.
Topic: Compile script to .exe with attached files
Replies: 8
Views: 9519

Re: Compile script to .exe with attached files

I worked with that notion some while ago. In general it's possible to attach arbitrary data to an exe file, and thus generalize embedding into having multiple files, by overriding some file access functions to use that data where appropriate. In particular you would override load , file? and read-fi...
by ralph.ronnquist
Sat May 04, 2019 3:35 am
Forum: newLISP and the O.S.
Topic: How to run a dos command in win7 console by newlisp
Replies: 2
Views: 3105

Re: How to run a dos command in win7 console by newlisp

Presumably the terminal control is done by writing control codes to stdout, and in that case you should rather use ! instead of exec . I.e.: (! "cls") (! "color 0b") Alternatively at the interactive prompt, you can type the commands without parentheses and quoting by starting with the exclamation ma...
by ralph.ronnquist
Sun Apr 28, 2019 1:52 am
Forum: newLISP in the real world
Topic: difference result by eval in macro and in S-expr
Replies: 5
Views: 4887

Re: difference result by eval in macro and in S-expr

mmm, did you check http://www.newlisp.org/downloads/newlisp_manual.html#define-macro ? The key point is that for m , its parameter lst gets bound to the un-evaluated argument ' (+ 4 5) , whereas in example 2 the eval function's parameter gets the evaluated argument (+ 4 5) , i.e, without the single-...
by ralph.ronnquist
Sat Mar 30, 2019 1:42 am
Forum: newLISP and the O.S.
Topic: Newlisp-Apache-CGI Issues Again
Replies: 29
Views: 18067

Re: Newlisp-Apache-CGI Issues Again

RIght. And yet it's missing for newlisp. Apparently Apache has "SetEnv" and "PassEnv" directives that possibly would service your use case. Or else, I suppose you can wrap the script with a shell script for this purpose. Or if you like living on the edge, you could apply a binary editor to your newl...
by ralph.ronnquist
Sat Mar 30, 2019 1:12 am
Forum: newLISP and the O.S.
Topic: Newlisp-Apache-CGI Issues Again
Replies: 29
Views: 18067

Re: Newlisp-Apache-CGI Issues Again

Hey! Response header name 'Environment variable TMP not set, assuming /tmp .Content-Type' contains invalid characters, aborting request That error message shows that newlisp has an initial "complaint" about "TMP", which means what it says, and that complaint precedes the script output. It has nothin...
by ralph.ronnquist
Wed Mar 27, 2019 12:42 pm
Forum: newLISP and the O.S.
Topic: Newlisp-Apache-CGI Issues Again
Replies: 29
Views: 18067

Re: Newlisp-Apache-CGI Issues Again

Have you verified the byte sequence from the script, eg by running it manually and pipe its output into a file, which you the inspect with a hex code viewer? Or even perhaps like the following: % thescript | C:\bin\newlisp\newlisp.exe -e '(read 0 b 10000)(map char (explode b))' Note, I don't really ...
by ralph.ronnquist
Tue Mar 26, 2019 10:46 pm
Forum: newLISP and the O.S.
Topic: Newlisp-Apache-CGI Issues Again
Replies: 29
Views: 18067

Re: Newlisp-Apache-CGI Issues Again

afair, a CGI response that includes headers should have a very first line being the HTTP response status code, then the header lines, then an empty line, and then the payload. You may omit the headers part and start with the empty line, and then the CGI runner would insert a standard header componen...
by ralph.ronnquist
Tue Mar 26, 2019 9:40 pm
Forum: newLISP and the O.S.
Topic: Newlisp-Apache-CGI Issues Again
Replies: 29
Views: 18067

Re: Newlisp-Apache-CGI Issues Again

You might want to try the initial line

Code: Select all

Status: 200 OK
by ralph.ronnquist
Wed Mar 20, 2019 11:46 am
Forum: newLISP in the real world
Topic: Unexpected result in round
Replies: 3
Views: 3947

Re: Unexpected result in round

If you don't mind, I would point you at this fairly in-depth discussion about "representable numbers" https://en.wikipedia.org/wiki/Floating-point_arithmetic#Representable_numbers,_conversion_and_rounding which I think is the issue at hand here. In short, the numbers you see printed are the nearest ...
by ralph.ronnquist
Tue Mar 05, 2019 8:17 am
Forum: newLISP in the real world
Topic: let and letn
Replies: 4
Views: 3908

Re: let and letn

Hmm. I get

Code: Select all

(1 2 3 (4 5 6 7) (nil nil nil nil))
as I would expect.
by ralph.ronnquist
Mon Feb 18, 2019 1:03 am
Forum: newLISP and the O.S.
Topic: (directory) in Windows and UTF8
Replies: 6
Views: 6602

Re: (directory) in Windows and UTF8

This problem might be due to that the passed in strings are temporary, and that therefore their allocated space might be reclaimed too early, before the actual call is done. If that's the case, a wrapping like the following might do the trick (let ((IN "CP866") (OUT "UTF-8")) (libiconv_open (address...
by ralph.ronnquist
Thu Jan 31, 2019 12:50 am
Forum: newLISP in the real world
Topic: list of functions question
Replies: 3
Views: 3289

Re: list of functions question

(funclist 2) is the symbol myfunc, and not its "value", which is the function.
Thus, you would need to use

Code: Select all

(set 'afunc (eval (funclist 2)))
so as to make afunc be a copy of the function named by the (funclist 2) symbol.
by ralph.ronnquist
Sat Dec 22, 2018 4:21 am
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 5763

Re: anti-select elements of a list

So you might be looking for something like the following:

Code: Select all

(define (drop lst idx) (let (n -1) (clean (fn (x) (member (inc n) idx)) lst)))

> (drop '(5 4 3 2 1) '(1 2))
(5 2 1)