Re: Question about DayOfWeek
- To: mathgroup at smc.vnet.net
- Subject: [mg126199] Re: Question about DayOfWeek
- From: Dana DeLouis <dana01 at me.com>
- Date: Wed, 25 Apr 2012 00:31:03 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
> DayOfWeek[{1975,1,1}]==Thursday gives > Wednesday == Thursday and not False, as it should? Why is it so? Hi. I believe the few examples given in Help on the function DayOfWeek using Equal ( == ) were incorrect. The few examples given all just happen to return True. Since Wednesday is a Symbol, and not a numeric value, I believe one should use SameQ. Wednesday//Head Symbol What you are seeing is either this... x==x True or this... x==y x==y You want... x===x True x===y False Using one of the Help examples, notice the following. x==x==x True This expression reduced to x==y x==x==y x==y Just note the following... Needs["Calendar`"] DayOfWeek[{2000, 1, 1}] Saturday So, using a given example in Help, they just happen to all be the same Symbol, so True... DayOfWeek[{2000, 1, 1}] == DayOfWeek[{2000, 1, 1 }] == DayOfWeek[{2000, 1, 1}] True Here, the last is a different symbol, so reduces to ... DayOfWeek[{2000, 1, 1}] == DayOfWeek[{2000, 1, 1 }] == DayOfWeek[{2000, 1, 2}] Saturday==Sunday So, it appears Equal doesn't work as expected, ... Table[DayOfWeek[{2012,1,d}] == Monday, {d,1,30}] //TableForm <omitted> But SameQ appears to work comparing symbols... Table[DayOfWeek[{2012,1,d}] === Monday, {d,1,30}] //TableForm False True False False ...etc = = = = = = = = = = Good luck. HTH :>) Dana DeLouis Mac & Math 8 = = = = = = = = = = On Apr 24, 5:37 am, Kent Holing <K... at statoil.com> wrote: > DayOfWeek[{1975,1,1}]==Wednesday gives True (as it should), but DayOfWeek[{1975,1,1}]==Thursday gives > Wednesday == Thursday and not False, as it should? Why is it so?