List or quoted List

Started by ssqq, May 29, 2014, 04:36:12 PM

Previous topic - Next topic

ssqq

function map accept a quoted list as its seconds arguments:



     (map inc '(1 2 3 4 5))



but above expression returned a list? or a quoted list? I think its should be a quoted list, because it could used with second map:



     (map inc (map inc '(1 2 3 4)))



I don't know if it is a macro with map, but the expression with map is evaluted with some delay.



How to know a primitive function is macro or common function?



The evaluted order about primitive function? I know `eval` is first should be evaluate than `println`.

cormullion

#1
Quote(map inc '(1 2 3 4 5))

  but above expression returned a list? or a quoted list?


It returns an unevaluated list:


(2 3 4 5)

As does:


'(1 2 3 4)
(1 2 3 4)


which is why you can do:


(map inc (map inc '(1 2 3 4))
;-> (3 4 5 6)


I don't think built-in functions are exactly macros, but many of them have special behaviour: e.g. if fortunately does not evaluate all the expressions passed to it. If it did, programming would be very difficult...

ssqq

#2
I think must have a type of data structure -> 'lazy-list' in newLISP, which would not be evaluted when passed into function as argument. most of list processing function would return a 'lazy-list'.