Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

CommonLisp:

* (if '() 'true 'false)
FALSE

Scheme:

> (if '() 'true 'false)
true

And back in CommonLisp:

* (cons (quote (a b c)) nil)
((A B C))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top