Search found 183 matches
- Thu Jul 09, 2020 4:12 pm
- Forum: newLISP in the real world
- Topic: List of user symbols
- Replies: 0
- Views: 4277
List of user symbols
A function to list the user symbols: (define (user-symbols) (local (_func _other) (setq _func '()) (setq _other '()) (dolist (_el (symbols)) (if (and (lambda? (eval _el)) (not (= _el 'user-symbols))) (push _el _func -1)) (if (and (not (lambda? (eval _el))) (not (primitive? (eval _el))) (not (protect...
- Fri Jul 03, 2020 10:26 am
- Forum: newLISP in the real world
- Topic: Sum of integers in a string
- Replies: 7
- Views: 5529
Re: Sum of integers in a string
thank you. I learned new things.
- Wed Jul 01, 2020 12:50 pm
- Forum: newLISP in the real world
- Topic: Sum of integers in a string
- Replies: 7
- Views: 5529
Re: Sum of integers in a string
Hi fdb, thanks for your functions. Only a problem: numbers with leading 0 will convert in octal base. Es. (parse-str "o123p010iru5") -> 136 (the correct value is 138) My function: (define (sum-str str) (local (numeri expr) (setq numeri '()) (setq expr {[0-9]+}) (replace expr str (push $0 numeri -1) ...
- Tue Jun 30, 2020 3:37 pm
- Forum: newLISP in the real world
- Topic: Sum of integers in a string
- Replies: 7
- Views: 5529
Sum of integers in a string
A string consist of digits and non-digit characters. The digits contains a series of positive integers. For instance, the string “abc22zit62de0f” contains the integers 22, 62 and 0.
Write a function to calculate the sum of the integers inside a string (es. 22 + 62 + 0 = 84)
Write a function to calculate the sum of the integers inside a string (es. 22 + 62 + 0 = 84)
- Wed Jun 17, 2020 10:01 am
- Forum: newLISP in the real world
- Topic: Sorting nil and true
- Replies: 1
- Views: 2502
Re: Sorting nil and true
I have found this method:
cameyo
Code: Select all
(setq lst '(true nil true b a))
(map sym (sort (map string lst)))
;-> (a b nil true true)
- Tue Jun 16, 2020 9:10 am
- Forum: newLISP in the real world
- Topic: Sorting nil and true
- Replies: 1
- Views: 2502
Sorting nil and true
How to sort a list containing nil and true symbols?
Thanks
Code: Select all
(setq a '(nil true b a))
(sort a)
;-> (nil true a b)
- Wed Jun 03, 2020 9:36 am
- Forum: newLISP newS
- Topic: Forum is back again
- Replies: 2
- Views: 5157
Re: Forum is back again
Thanks to the administrator ... and to all the newlisp programmers
Massimo
Massimo
- Mon May 25, 2020 11:51 am
- Forum: newLISP in the real world
- Topic: From "The Little Schemer" to newLISP
- Replies: 2
- Views: 3108
Re: From "The Little Schemer" to newLISP
Thanks newBert.
Wrong method of passing parameters in my function.
Wrong method of passing parameters in my function.
- Mon May 25, 2020 9:15 am
- Forum: newLISP in the real world
- Topic: From "The Little Schemer" to newLISP
- Replies: 2
- Views: 3108
From "The Little Schemer" to newLISP
I am reading the book "The Little Schemer" (yes, i know newLISP is different from Scheme...but i'm learning) Until chapter 8 i had no problem to translate the code in newLISP. But now i have the following function: (define (rember-f test?) (lambda (a l) (cond ((null? l) '()) ((test? (first l) a) (re...
- Mon May 25, 2020 8:54 am
- Forum: newLISP in the real world
- Topic: Parallel assignment
- Replies: 3
- Views: 3514
Re: Parallel assignment
Thanks !
I suspected that the map function could have been useful... :-)
I suspected that the map function could have been useful... :-)
- Mon May 25, 2020 7:33 am
- Forum: newLISP in the real world
- Topic: Parallel assignment
- Replies: 3
- Views: 3514
Parallel assignment
Hi all, this is my first macro to do parallel assignment: (define-macro (psetq) (let ((_var '()) (_ex '())) ; for each expression in (args 1) ... (for (i 0 (- (length (args 1)) 1)) ; expand the i-th expression with the value ; of each variable in (args 0) (setq _ex (expand (args 1 i) (args 0 0))) ; ...
- Sun Nov 24, 2019 2:02 pm
- Forum: newLISP in the real world
- Topic: Puzzle
- Replies: 5
- Views: 6447
Re: Puzzle
@ralph.ronnquist : you right :-) @fbd : another good lisp-style solution Solution: One method is to separate the sign and magnitude of the number by the parity of the number. We have three cases: 1) If the number is even, it keeps the same sign and moves 1 closer to 0 (subtract 1 from a positive ev...
- Sat Nov 23, 2019 1:38 pm
- Forum: newLISP in the real world
- Topic: Puzzle
- Replies: 5
- Views: 6447
Re: Puzzle
Hi fdb, nice solution :-)
However it is possible to solve the puzzle using a "normal" function with any programming language.
However it is possible to solve the puzzle using a "normal" function with any programming language.
- Thu Nov 21, 2019 1:05 pm
- Forum: newLISP in the real world
- Topic: Puzzle
- Replies: 5
- Views: 6447
Puzzle
Write a function f so that f (f (n)) = -n for every integer n.
I'll post the solution the next week :-)
Code: Select all
Examples:
(f (f -1)) = 1
(f (f 1)) = -1
(f (f 4)) = -4
(f (f -4)) = 4
(f (f 0)) = 0
- Thu Nov 21, 2019 8:03 am
- Forum: newLISP in the real world
- Topic: Fractran language
- Replies: 8
- Views: 5254
Re: Fractran language
Thanks for another function for big integer :-)
- Wed Nov 20, 2019 7:20 pm
- Forum: newLISP in the real world
- Topic: Fractran language
- Replies: 8
- Views: 5254
Re: Fractran language
Hi ralph.ronnquist,
i have some problems with your function.
I think that the bits function don't work with big integer.
Have a nice day
i have some problems with your function.
I think that the bits function don't work with big integer.
Have a nice day
- Mon Nov 18, 2019 3:51 pm
- Forum: newLISP in the real world
- Topic: Fractran language
- Replies: 8
- Views: 5254
Fractran language
Fractran is a Turing-complete esoteric programming language invented by the mathematician John Conway. A Fractran program is an ordered list of positive fractions together with an initial positive integer input n. The program is run by updating the integer n as follows: 1) For the first fraction f i...
- Fri Nov 01, 2019 2:40 pm
- Forum: newLISP in the real world
- Topic: Tree structure
- Replies: 2
- Views: 3357
Re: Tree structure
Some basic functions on binary trees. Maybe these can be useful to other beginners like me... List structure of a tree --> (V L R) where V = tree Value L = Left sub-tree R = Right sub-tree leaf --> (V nul nul) Example: A / \ / \ B C / / \ / / \ D E F (setq my-tree '(A (B (D nul nul)) (C (E nul nul) ...
- Wed Oct 30, 2019 5:04 pm
- Forum: newLISP in the real world
- Topic: Tree structure
- Replies: 2
- Views: 3357
Re: Tree structure
To start:
"Simply Scheme" Harvey-Wright (Chapter 18)
"SICP" Abelman-Sussman (2.2.2 Hierarchical Structures)
...
binary trees, binary search trees, AVL trees, 2-3-4 trees, red-black trees... it is a long road :-)
"Simply Scheme" Harvey-Wright (Chapter 18)
"SICP" Abelman-Sussman (2.2.2 Hierarchical Structures)
...
binary trees, binary search trees, AVL trees, 2-3-4 trees, red-black trees... it is a long road :-)
- Mon Oct 21, 2019 10:10 am
- Forum: newLISP in the real world
- Topic: Tree structure
- Replies: 2
- Views: 3357
Tree structure
Which is the best way to represent a tree with a list?
Do you know newLISP code that works with trees?
Thanks
Do you know newLISP code that works with trees?
Thanks
- Wed Oct 16, 2019 7:50 am
- Forum: newLISP in the real world
- Topic: newLISP at the University of Utah
- Replies: 2
- Views: 3610
- Fri Oct 04, 2019 9:22 am
- Forum: newLISP in the real world
- Topic: difference result by eval in macro and in S-expr
- Replies: 5
- Views: 4889
Re: difference result by eval in macro and in S-expr
Hi lyl,
i'm not an expert, but i think "evaluated" is different from "expanded". Maybe a guru will highligth this question.
The typeof function show the type of the argument; the core function is dump (see the manual for information).
ciao
i'm not an expert, but i think "evaluated" is different from "expanded". Maybe a guru will highligth this question.
The typeof function show the type of the argument; the core function is dump (see the manual for information).
ciao
- Thu Oct 03, 2019 6:22 pm
- Forum: newLISP in the real world
- Topic: difference result by eval in macro and in S-expr
- Replies: 5
- Views: 4889
Re: difference result by eval in macro and in S-expr
Maybe you can use letex : (define(f lst) (letex (x lst) (+ x 1))) (setq a '(+ 2 3)) ;-> (+ 2 3) (f a) ;-> 6 Try this: (define types '("nil" "true" "int" "float" "string" "symbol" "context" "primitive" "import" "ffi" "quote" "expression" "lambda" "fexpr" "array" "dyn_symbol")) (define (typeof v) (typ...
- Thu Sep 26, 2019 10:56 am
- Forum: So, what can you actually DO with newLISP?
- Topic: Quine
- Replies: 0
- Views: 5924
Quine
A Quine on REPL:
Have a nice day
Code: Select all
ERR: context expected : ERR:
;-> ERR: context expected : ERR:
- Wed Sep 25, 2019 3:37 pm
- Forum: newLISP in the real world
- Topic: replace parentheses of a list with quotation marks
- Replies: 2
- Views: 3200
Re: replace parentheses of a list with quotation marks
Maybe in this way: (setq a "time") ;-> "time" (setq b '(set xlabel a)) ;-> (set xlabel a) (define (lst-str lst) (setf (last lst) (eval (last lst))) (join (map string lst) " ")) (lst-str b) ;-> "set xlabel time" or (define (lst-str lst) (setf (last lst) (append "\"" (eval (last lst)) "\"")) (join (ma...