What is ' (apostrophe) in Lisp / Scheme?

后端 未结 7 657
情深已故
情深已故 2021-02-01 12:16

I am on day 1 hour 1 of teaching myself Scheme. Needless to say, I don\'t understand anything. So I\'m reading The Little Schemer and using this thing:

7条回答
  •  温柔的废话
    2021-02-01 12:52

    If you looking for a best IDE for scheme then go for Dr Racket. But when start Dr Racket first line should be #lang scheme since Dr Racket has many language we have explicitly mention which language we are going to use.

    When we want to pass an argument itself instead of passing the value of the argument then we use quote. It is mostly related to the procedure passing during using lists, pairs and atoms which are not available in C programming Language ( most people start programming using C programming, Hence we get confused) This is code in Scheme programming language which is a dialect of lisp and I guess you can understand this code.

    (define atom?              ; defining a procedure atom?
    (lambda (x)              ; which as one argument x
    (and (not (null? x)) (not(pair? x) )))) ; checks if the argument is atom or not
    (atom? '(a b c)) ; since it is a list it is false #f
    

    The last line (atom? 'abc) is passing abc as it is to the procedure to check if abc is an atom or not, but when you pass(atom? abc) then it checks for the value of abc and passses the value to it. Since, we haven't provided any value to it

提交回复
热议问题