SetAttributesAnyTrue, HoldAll; AnyTrueexpr_, {var_Symbol, lis_List} := LengthWhilelis, NotTrueQReleaseHoldHoldexpr /. HoldPatternvar -> # & (but I realize building up the unevaluated terms with e.g. Table is a pain): In173:= OrPrint1;True, Print2;False During evaluation of In173:= 1 Out173= True.
Yup, works perfect – Yaroslav Bulatov Nov 15 '10 at 7:31 1 coming late, I'd just point out that excessive details in argument patterns do not often go well with Hold attributes. For example, the following call fails: AnyTruei Also, AnyTrue doesn't work in M8 on packed lists - there seems to be a bug in LengthWhile: LengthWhileRange5,! TrueQ# It would be better to have a more general pattern and validate the argument after evaluating it.
HoldAll instead of HoldFirst is necessary since we want to keep var held in addition to expr, otherwise there wouldn't be an issue with the more discerning pattern. – Michael Pilat Jan 13 at 2:22 @Leonid -- I have just noticed the comment about PackedArray bug, and I wish I saw it earlier!..."@Yaroslav" would send notification to me, whereas Michael is notified automatically since comment is on his answer meta.stackoverflow. Com/questions/71903/… – Yaroslav Bulatov Feb 6 at 5:55 @Yaroslav - Sorry, I thought the owner of the question is notified automatically.
I should learn this SO mechanics better! Anyway, I wrote a similar function myself for my own uses a while ago, that one does not rely on LengthWhile and should be fine (but it suffers from the same pattern-matching problem as Michael's - could be fixed in principle) - see my reply to your post. – Leonid Shifrin Feb 6 at 11:59.
This doesn't match your spec but I often use the following utility functions, which are similar to what you have in mind (they use pure functions instead of expressions with a specified variable) and also do short-circuiting: somef_, l_List := True === (* Whether f applied to some *) ScanIff#, ReturnTrue&, l; (* element of list is True. *) everyf_, l_List := Null === (* Similarly, And @@ f/@l *) ScanIf! F#, ReturnFalse&, l; (* (but with lazy evaluation).
*) For example, Michael Pilat's example would become this: In1:= some(Print"x=", #; # == 3)&, {1, 2, 3, 4, 5} During evaluation of In1:= x=1 During evaluation of In1:= x=2 During evaluation of In1:= x=3 Out1= True.
1 Useful trick. Note, using "If" instead of "TrueQ" requires a bit more care with syntax, ie everyFalse, {a, {1, 3, 5}} gives "True" – Yaroslav Bulatov Nov 18 '10 at 9:15 You had me worried at first but I don't think there's a bug here. Note that the first argument needs to be a function.
EveryFalse&, {1,3,5} works as expected. – dreeves Nov 18 '10 at 9:31 Right, no bug, just a subtle semantic difference, since it's "True" if f evaluates to "something other than False" for every element of the list – Yaroslav Bulatov Nov 18 '10 at 9:43.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.