Search found 598 matches
- Fri Jan 01, 2021 7:09 pm
- Forum: Whither newLISP?
- Topic: "place" in the function "inc"
- Replies: 5
- Views: 1665
Re: "place" in the function "inc"
Hi octowuss, and welcome! That doesn't make any sense [...] and wanted to learn more Lisp, but this version is full of these incomprehensible "gimmicks" that make it very difficult to work out how to use it! Well, the OP was really asking about a very obscure "corner case" usage of `inc` to accompli...
- Thu Oct 08, 2020 1:56 am
- Forum: newLISP and the O.S.
- Topic: fun with pledge()
- Replies: 2
- Views: 646
Re: fun with pledge()
Nice! 👍
- Tue Aug 25, 2020 1:34 pm
- Forum: newLISP in the real world
- Topic: running a nL on nearlyfreespeech
- Replies: 8
- Views: 1001
Re: running a nL on nearlyfreespeech
Your #! line looks wrong.
- Fri Oct 11, 2019 11:40 pm
- Forum: newLISP in the real world
- Topic: values into mul
- Replies: 2
- Views: 993
Re: values into mul
Use read-expr.
Code: Select all
(println (mul 2 (read-expr abc)))
- Fri Sep 20, 2019 5:30 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
Over time envrironment and stack memory gets fragmented by certain functions. The error forces a total low level freeing and reallocation of this memory. There is nothing we can do about it without slowing down everywhere, but it is a rare enough problem. Until now, I have never seen this before. T...
- Fri Sep 20, 2019 1:36 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
cameyo, thank you for raising this issue!
- Fri Sep 20, 2019 12:44 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
@rickyboy and @ralph.ronnquist Sorry, I didn't explain myself well. The function i tried was "merge" with temporary heap function. Yes, you are correct. I remember testing this myself before I first posted here (as I had the same idea as Ralph). I ruled that out as a possibility when I saw what you...
- Thu Sep 19, 2019 10:01 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
I upgraded my newLISP. Still works fine. $ ./newlisp newLISP v.10.7.5 64-bit on BSD IPv4/6 UTF-8 libffi, options: newlisp -h > (define (merge lstA lstB op) (sort (append lstA lstB) op)) (lambda (lstA lstB op) (sort (append lstA lstB) op)) > (time (merge (sequence 1 500) (sequence 1 200) <) 500) 594....
- Thu Sep 19, 2019 7:06 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
@ralph.ronnquist: I have tried your function (in a fresh REPL), but the result are the same: > (time (merge (sequence 1 500) (sequence 1 200) <) 500) 1842.392 > (time (merge (sequence 1 500) (sequence 1 200) <) 500) 2290.107 > (time (merge (sequence 1 500) (sequence 1 200) <) 500) 2831.184 > (time ...
- Wed Sep 18, 2019 5:29 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
P.S. Calling your merge function with smaller inputs doesn't cause a ramp up of timings. (setq C '(4 3 2)) (setq D '(8 5 3 1)) (time (merge C D >) 500) Here's the REPL output as I continually press Ctrl-x Ctrl-e (newlisp-eval) with my cursor on the time call (in Emacs). > 2.712 > 2.777 > 2.682 > 2.6...
- Wed Sep 18, 2019 5:17 pm
- Forum: newLISP in the real world
- Topic: Timing function problem
- Replies: 19
- Views: 3687
Re: Timing function problem
Yeah, I don't know precisely what's causing that, but when you use a loop (instead of an iterative recursive call), this problem goes away. (define (merge-via-loop lstA lstB op) (let (out '()) (until (or (null? lstA) (null? lstB)) (push (if (op (first lstB) (first lstA)) (pop lstB) (pop lstA)) out -...
- Tue Sep 03, 2019 6:03 pm
- Forum: newLISP in the real world
- Topic: what's wrong with the use of apply append
- Replies: 4
- Views: 1161
Re: what's wrong with the use of apply append
The symbol 'var which is passed to "append" has been binded to "b", why is the evaluator not able to see it? The short answer is: because the quote prevents it from getting evaluated, as in: > (setq var "b") "b" > 'var var > var "b" Here, the single quote character (preceding var ) prevents var fro...
- Tue Sep 03, 2019 9:49 am
- Forum: newLISP in the real world
- Topic: what's wrong with the use of apply append
- Replies: 4
- Views: 1161
Re: what's wrong with the use of apply append
What we were missing was the error message: > (setq var "b") "b" > (apply append '("a" var)) ;; I believe the result will be "ab", but what I get is error message. ERR: string expected in function append : 'var The problem is that in the expression '("a" var) , var is getting quoted; so, you end up ...
- Wed Aug 28, 2019 12:43 am
- Forum: newLISP in the real world
- Topic: Create polynomials
- Replies: 3
- Views: 1254
Re: Create polynomials
Here's a version of the lambda builder that constructs the body according to the method of Horner . (define (make-poly-horner coeffs) (push (if (< (length coeffs) 2) (first coeffs) (apply (fn (acc c) (list 'add c (cons 'mul (list 'x acc)))) coeffs 2)) (copy '(fn (x))) -1)) To give you an idea of wha...
- Sat Jul 13, 2019 9:04 pm
- Forum: newLISP in the real world
- Topic: Pathological floating point problems
- Replies: 2
- Views: 1071
Re: Pathological floating point problems
That's very cool. And a good thing to keep in mind when doing computer arithmetic. But, your code could be much shorter -- it would then be more readable to others (and to you, months or years later :). (define (rat n d) (let (g (gcd n d)) (map (curry * 1L) (list (/ n g) (/ d g))))) (define (+rat r1...
- Sat Jul 13, 2019 6:00 pm
- Forum: Whither newLISP?
- Topic: pseudo-random number generator
- Replies: 1
- Views: 1989
Re: pseudo-random number generator
I'm not an expert at PRNGs, but here is the implementation in newlisp.
https://github.com/kosh04/newlisp/blob/ ... 1709-L1764
https://github.com/kosh04/newlisp/blob/ ... 1709-L1764
- Mon Jun 03, 2019 10:35 am
- Forum: newLISP in the real world
- Topic: Sum of digits
- Replies: 4
- Views: 1570
Re: Sum of digits
Getta via il 9. :) https://en.wikipedia.org/wiki/Casting_out_nines
- Sat Jun 01, 2019 11:37 pm
- Forum: newLISP newS
- Topic: newLISP language support for Visual Studio Code
- Replies: 9
- Views: 4475
Re: newLISP language support for Visual Studio Code
Nice!
I would collab but I don't use VS Code (nor linux, nor windows, nor mac). :)
(However, I just sent a PR on your other gh project.) Best, --Rick
I would collab but I don't use VS Code (nor linux, nor windows, nor mac). :)
(However, I just sent a PR on your other gh project.) Best, --Rick
- Thu May 30, 2019 9:18 pm
- Forum: newLISP in the real world
- Topic: Maximum Product Sublist
- Replies: 5
- Views: 1549
Re: Maximum Product Sublist
Hi rickyboy Hi cameyo! :) the sublist must contains only contiguous elements. But your functions are useful anyway :-) Ah, ok! Then my updated maxProd function is still very similar to my original. (define (maxProd lst) ;; lst must contain integers; note use of integer op `*`. (apply max (map (fn (...
- Thu May 30, 2019 6:57 pm
- Forum: newLISP in the real world
- Topic: Maximum Product Sublist
- Replies: 5
- Views: 1549
Re: Maximum Product Sublist
Here's my version. (define (maxProd lst) ;; lst must contain integers; note use of integer op `*`. (apply max (map (fn (prods) (apply * prods)) (remove '() (powerset lst))))) You'll need these functions. (define (mappend) (apply append (apply map (args)))) (define (powerset s) (if s (mappend (fn (x)...
- Thu May 30, 2019 6:08 pm
- Forum: newLISP in the real world
- Topic: Group the elements of a list
- Replies: 10
- Views: 2387
Re: Group the elements of a list
While I was exploring all the code, I believe that I found a bug. The following identity should hold: the reachability of the transitive closure of input is the same as the reachability of input . > (set-equal? (reachability input) (reachability (transD input))) nil Hmmm. What's going on? > (reachab...
- Thu May 30, 2019 5:42 pm
- Forum: newLISP in the real world
- Topic: Group the elements of a list
- Replies: 10
- Views: 2387
Re: Group the elements of a list
Then, how do you go the other way? I.e. how do you reduce into the smallest number of pairs, or at least find a sub list so that implied relationships are omitted from the list? Well, I perceive that you know the answer already, so I thank you for letting us share in the fun. :) Here is a function ...
- Wed May 29, 2019 11:29 pm
- Forum: newLISP in the real world
- Topic: Group the elements of a list
- Replies: 10
- Views: 2387
Re: Group the elements of a list
A recursive solution could be something like this: (define (trans s (x s) (f (and s (curry intersect (first s))))) (if s (trans (rest s) (cons (unique (flat (filter f x))) (clean f x))) x)) Perhaps there is something faster. Looks good, Ralph! I don't think I could do it faster. I prefer your code ...
- Tue May 28, 2019 7:02 pm
- Forum: newLISP in the real world
- Topic: Group the elements of a list
- Replies: 10
- Views: 2387
Re: Group the elements of a list
Right on, fdb! Lutz wins this round! :)
- Mon May 27, 2019 11:26 pm
- Forum: newLISP in the real world
- Topic: Nesting level of a list
- Replies: 5
- Views: 1434
Re: Nesting level of a list
Excellent, fdb! Faster than mine by about a factor of 3 (on the sample input)! 2.5 times faster than the original.