Nп/п : 74 из 93
 От   : Tom Russ                            2:5075/128        11 сен 23 11:09:02
 К    : none) (albert                                         11 сен 23 21:11:03
 Тема : Re: clojure / MAL confusion about true.
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
<769eadf4-96c0-4632-b1c8-8117d20567c7n@googlegroups.com> 9bc88b5b
@REPLY:
dfbccd10
@REPLYADDR Tom Russ <taruss@google.com>
@REPLYTO 2:5075/128 Tom Russ
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:

@RFC-Message-ID:
<769eadf4-96c0-4632-b1c8-8117d20567c7n@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
On Saturday, September 9, 2023 at 1:47:23 PM UTC-7, none albert wrote:
> I`m working with MAL that is supposed to be a Clojure clone. 
> I`m surprised to see the following. 
> Almost nothing is consider false in the second position 
> in the `if construct, however asking for a truth value explicitly 
> by `true? is different. (Naively I borrowed the code for if, 
> routinely isolated in a separate function, and used this for `true? ). 
> Testing failed, thus I checked with the Clojure installed on my system. 

> " 
> Clojure 1.10.1 
> user=> (true? true) 
> true 
> user=> (if true? 1 2) 
> 1 
> user=> (true? true?) 
> false 
> " 

> Is there a reason for this? 

 (a) That is the way Clojure defines the IF operator. Only FALSE or
NIL are false.
 (b) That is traditionally the way Lisp defined the IF operator.
Only NIL was false.

TRUE? is a function, so as an object it will not be considered equal to
the value TRUE.  So asking if the function TRUE? is the value TRUE 
will return false.  https://clojuredocs.org/clojure.core/true q

Now, the IF statement works differently. It will treat any value except FALSE
or NIL as being true. https://clojuredocs.org/clojure.core/if

--- G2/1.0
 * Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх