newLISP Fan Club

Forum => newLISP in the real world => Topic started by: ssqq on May 29, 2014, 04:36:12 PM

Title: List or quoted List
Post by: ssqq on May 29, 2014, 04:36:12 PM
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`.
Title: Re: List or quoted List
Post by: cormullion on May 30, 2014, 01:41:50 AM
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...
Title: Re: List or quoted List
Post by: ssqq on May 30, 2014, 05:25:02 PM
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'.