Search found 88 matches

by ssqq
Thu Sep 15, 2016 1:23 am
Forum: Anything else we might add?
Topic: first or last empty list should return nil
Replies: 1
Views: 4265

first or last empty list should return nil

When `rest` or `chop` or `filter` a list, empty list would be create. But many function that process list would throw error with empty list (first last rest nth). So newlisper need treate empty list as special list to avoid code crash. If index empty list return nil, then would simplify coding proce...
by ssqq
Thu Sep 15, 2016 1:15 am
Forum: Anything else we might add?
Topic: (define (name, local-decalre) ..) would lost (args)
Replies: 1
Views: 4305

Re: (define (name, local-decalre) ..) would lost (args)

I think newlisp treat `,` and follow args as extra args, so assign them with nil in default and init in *args stack*.
by ssqq
Tue Sep 13, 2016 3:41 pm
Forum: Anything else we might add?
Topic: (define (name, local-decalre) ..) would lost (args)
Replies: 1
Views: 4305

(define (name, local-decalre) ..) would lost (args)

> (define (show-args) (println (args))) (lambda () (println (args))) > (show-args 1 2 3) (1 2 3) (1 2 3) > (define (show-args,@x) (println (args))) (lambda (, @x) (println (args))) > (show-args 1 2 3) (3) (3) > (define (show-args @x, @y) (println @x (args))) (lambda (@x , @y) (println @x (args))) >...
by ssqq
Tue Sep 13, 2016 3:35 pm
Forum: newLISP in the real world
Topic: how to know the current process id?
Replies: 3
Views: 4691

Re: how to know the current process id?

I have not use process, because switch at Windows and Ubuntu.
by ssqq
Sat Sep 03, 2016 4:00 am
Forum: Anything else we might add?
Topic: Strange reader
Replies: 5
Views: 10826

Re: Strange reader

Now follow expr is ok:

Code: Select all

> (sym "fn")
fn
> (sym "lambda")
lambda
> (sym "lambda-macro")
lambda-macro

> (lambda? (cons (sym "fn")))
nil
;; but get lambda exprssion in dynamically is not ok
> (lambda? (eval (cons (sym "fn"))))
ERR: invalid function : (fn)

by ssqq
Mon Aug 22, 2016 2:12 pm
Forum: Anything else we might add?
Topic: case design
Replies: 2
Views: 6415

case design

(constant 'Type 1) (define (check-type x) (case (Type (println "it is Type")) (true (println "it is not Type")))) (check-name 1) (exit) ==> it is not Type For: case syntax: (case exp-switch (exp-1 body-1) [(exp-2 body-2) ... ]) The result of evaluating exp-switch is compared to each of the unevalua...
by ssqq
Fri Aug 05, 2016 5:11 pm
Forum: newLISP in the real world
Topic: How to add stack size when -x code to executable file
Replies: 2
Views: 4016

Re: How to add stack size when -x code to executable file

I found my stack over flow is code design have problem, when call a function with recursive over 50> times, would occur this error.

Code: Select all

> (define (call x) (cond ((= x 1) x) (true (dec x) (+ x (call x)))))
> (call 1000)
ERROR: stack over flow
by ssqq
Fri Aug 05, 2016 8:04 am
Forum: newLISP in the real world
Topic: intersect bug?
Replies: 4
Views: 5743

Re: intersect bug?

intersect syntax: (intersect list-A list-B) syntax: (intersect list-A list-B bool) If you want intersect more list: > (set '@lst '((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7))) ((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7)) > (map (curry apply intersect) (explode @lst 2)) ((2 3 4) (4 5 6)) > (apply intersec...
by ssqq
Thu Aug 04, 2016 9:08 am
Forum: newLISP in the real world
Topic: memory leak? antiprimes
Replies: 15
Views: 9676

Re: memory leak? antiprimes

I could not run this code: combinations (2 2) 1 ():list level 0 extend yields list? true combinations (2) 1 (2):list level 1 extend yields list? true combinations () 1 (2):list level 1 combinations (2 2) 2 ():list level 0 extend yields list? combinations () 2 (2 2):list level 2 true combinations (2)...
by ssqq
Thu Aug 04, 2016 5:08 am
Forum: newLISP in the real world
Topic: memory leak? antiprimes
Replies: 15
Views: 9676

Re: memory leak? antiprimes

Code: Select all

> (define (ex @x) (extend "a" @x))
(lambda (@x) (extend "a" @x))
> (map ex (explode "abc"))
("aa" "aab" "aabc")
by ssqq
Tue Aug 02, 2016 5:15 pm
Forum: Anything else we might add?
Topic: char "{" could not write in char class with {..}
Replies: 2
Views: 5102

Re: char "{" could not write in char class with {..}

But if code is in file, it is OK.

Code: Select all

ssqq@X61:~/spp-newlisp$ cat debug.lsp 
(constant 'say println)

(define (regex-str-char @str)
  (replace {([\Q()[]{}|\.+*?^$\E])} @str (string {\} $1) 0))

(say (regex-str-char "{}()"))

(exit)
ssqq@X61:~/spp-newlisp$ newlisp debug.lsp 
\{\}\(\)

by ssqq
Tue Aug 02, 2016 5:10 pm
Forum: Anything else we might add?
Topic: char "{" could not write in char class with {..}
Replies: 2
Views: 5102

Re: char "{" could not write in char class with {..}

Code: Select all

> {[\Q{\E]}
ERR: string token too long : "[\\Q{\\E]}"
> {[\Q\{\E]}
ERR: string token too long : "[\\Q\\{\\E]}"
by ssqq
Tue Aug 02, 2016 2:45 pm
Forum: Anything else we might add?
Topic: char "{" could not write in char class with {..}
Replies: 2
Views: 5102

char "{" could not write in char class with {..}

Code: Select all

> {[{]}

ERR: string token too long : "[{]}"
> {[\{]}

ERR: string token too long : "[\\{]}"
;; \nnn also could not recognize in {..}
> {\123}
"\\123"

by ssqq
Tue Aug 02, 2016 2:40 pm
Forum: Anything else we might add?
Topic: -nan is not number
Replies: 4
Views: 5929

Re: -nan is not number

I see, Reason is ANSI C could not support.
by ssqq
Tue Aug 02, 2016 11:39 am
Forum: newLISP in the real world
Topic: memory leak? antiprimes
Replies: 15
Views: 9676

Re: memory leak? antiprimes

4: 2
ERR: invalid function in function if : (prime? f)
called from user function (antiprime)

“extend” would treat first argument as place and Increase by degress,you'd better use cons or other ...
by ssqq
Mon Aug 01, 2016 8:56 am
Forum: Anything else we might add?
Topic: -nan is not number
Replies: 4
Views: 5929

-nan is not number

-nan (NaN) should not return true with number?

Code: Select all

> (set 'nan (sqrt -1))
> (number? nan)
true ;; should return nil
Also advise with inf. I think all NaN and Inf are "error status" that may not throw error immediatly.
So they isn't value.
by ssqq
Mon Aug 01, 2016 8:08 am
Forum: newLISP in the real world
Topic: How to avoid stack overflow
Replies: 1
Views: 3604

How to avoid stack overflow

I don't know how resume stack space in newLISP.

If I use one function do too much thiings, then the stack of function may occur stack overflow?

If i reject the return value when call other function, then would avoid stack overflow?

If anyone could give me some advise?
by ssqq
Sun Jul 31, 2016 1:03 pm
Forum: newLISP in the real world
Topic: How to add stack size when -x code to executable file
Replies: 2
Views: 4016

How to add stack size when -x code to executable file

Code: Select all

ERR: call or result stack overflow in function set : term
When I see this error, I think the stack size is too small. How to enlarge it in default?
by ssqq
Sat Jul 30, 2016 7:14 am
Forum: So, what can you actually DO with newLISP?
Topic: Good tools for tidy and lint newlisp code
Replies: 1
Views: 5120

Re: Good tools for tidy and lint newlisp code

When we use newlisp write code, the interpreter could not do anything for us. Because newLISP must be rapidly, more and more. So, we could do something for to more stable code: 1. un-used symbol: (define (foo x y) (+ x 1)) below code, symbol 'y' have not used, It's may not any dangrous. but: (define...
by ssqq
Wed Jul 27, 2016 12:32 pm
Forum: newLISP in the real world
Topic: dangrous true?
Replies: 1
Views: 3600

dangrous true?

if you use true? as checking function for list, be attention to: blank list -> '(), would not match it.

Code: Select all


> (true? '())
nil

If you often use it, advise you use :

Code: Select all

> (define (bool x) (if (nil? x) nil true))
> (for-all bool '(1 2 3 4 () 6))
by ssqq
Sun Jul 24, 2016 10:15 am
Forum: Anything else we might add?
Topic: primitive function empty? could not accept array
Replies: 13
Views: 12795

Re: primitive function empty? could not accept array

in newLISP, no "true" hash, is just assoc-list. I just want simulate Hash, Array use newlisp. Just like no Hash, List and symbol in C, but Lautz could write newLISP use C. I write Spp language implement with newLISP, it have Array, Hash, List, Rule: > (my @array []) [] > (@array << :a) [:a] > (my %h...
by ssqq
Sun Jul 24, 2016 7:52 am
Forum: So, what can you actually DO with newLISP?
Topic: Good tools for tidy and lint newlisp code
Replies: 1
Views: 5120

Good tools for tidy and lint newlisp code

I re-design these two tools now: tidy newlisp: could find loss ")" or more ")". while, letn, dotimes all indent two space. https://github.com/songzan/newlisp-spp/blob/master/tools/lint.lsp usage: > newlisp tidy.lsp target.lsp lint nelisp: could check un-declare symbol and un-used symbol. https://git...
by ssqq
Sun Jul 24, 2016 7:44 am
Forum: So, what can you actually DO with newLISP?
Topic: concurrent design for check
Replies: 5
Views: 6695

Re: concurrent design for check

I design a function model to implement "return" from any depth block. in general, when call (return sth) in function, current function namespace would find a return value have been ready. when return expression is in deep block, return message would be receive by main process after serval value pass...
by ssqq
Sat Jul 23, 2016 2:44 pm
Forum: So, what can you actually DO with newLISP?
Topic: concurrent design for check
Replies: 5
Views: 6695

concurrent design for check

I want check a variable value till another process send it to it, then do other thing. How to design it?

Code: Select all


(while (check-var-is-true) (do-some-thing))

by ssqq
Sat Jul 23, 2016 3:52 am
Forum: Anything else we might add?
Topic: primitive function empty? could not accept array
Replies: 13
Views: 12795

Re: primitive function empty? could not accept array

I need make array, hash, list use newLISP. SO i do like follows: (define (is-blank-array x) (= x '())) (define (is-list x) (list? x) (and (= (first x) "list") (list? (last x)))) (define (is-blank-hash x) (= x '(()))) (define (is-hash @x) (and (list? @x) (for-all is-pair @x))) (define (is-pair @x) (a...