Search code examples
schemeoutputcons

Scheme Cons (with #f as a second statement) output


I was wondering, If

(cons (quote (a b c)) #f)

gives an output

(( a  b  c ))

Then what output does this give:

(cons (quote (a b c)) #t)

?

Thank you


Solution

  • The first expression will not evaluate to ((a b c)) in most interpreters, it seems that your interpreter is evaluating #f as an empty list:

    (cons (quote (a b c)) '())
    => '((a b c))
    

    Having said that, you just substituted a #f with a #t, the standard results will look like this:

    (cons (quote (a b c)) #f)
    => '((a b c) . #f)
    
    (cons (quote (a b c)) #t)
    => '((a b c) . #t)
    

    Why don't you try it online? in here for instance.