array became list in silent

For the Compleat Fan
Post Reply
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

array became list in silent

Post by ssqq »

When I add a array to list, then index it, it would became list in silent.

Code: Select all

newLISP v.10.7.0 32-bit on Windows IPv4/6 libffi, options: newlisp -h

> (array? ((list 1 (array 3 '(1 2 3)) 3) 1))    
nil
> (list? ((list 1 (array 3 '(1 2 3)) 3) 1))     
true
I think array as value, when transfer to expression, it should be in definitely.

When I add a list to array, then index it, it also is list

Code: Select all

> (list? ((array 3 '(1 (2 3) 4)) 1))
true

ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: array became list in silent

Post by ssqq »

concat two element, invoid array became list in silent

Code: Select all

(define (concat) (apply _concat (args)))
(define (_concat @x @y)
  (cond
    ((atom? @x)
     (cond
       ((atom? @y) (cons @x @y))
       ((array? @y) (cons @x @y))
       ((list? @y) (push @y (list @x) -1))
       (true (error "error concat data"))))
    ((array? @x)
     (cond
       ((atom? @y) (cons @x @y))
       ((array? @y) (cons @x @y))
       ((list? @y) (push @x (list @y)))
       (true (error "error concat data"))))
    ((list? @x)
     (cond
       ((atom? @y) (cons @x @y))
       ((array? @y) (cons @x @y))
       ((list? @y) (list @x @y))
       (true (error "error concat data"))))
    (true (error "error concat data"))))

Post Reply