Skip to main content
18 events
when toggle format what by license comment
Nov 12 at 10:43 answer added Sjoerd Smit timeline score: 6
Nov 12 at 8:16 answer added Roman timeline score: 5
Nov 9 at 22:39 vote accept Andrew
Nov 9 at 22:39 history became hot network question
Nov 9 at 17:26 review Close votes
Nov 12 at 20:32
Nov 9 at 17:17 comment added Michael E2 Perhaps I misread?: If you wish a list of True/False, then what's wrong with Map[MatchQ["A" | "a"]]@myStrList? I suppose your question is really just about what Or[] means and how it works in Mathematica. Have you looked at the documentation, because its evaluation to only True or False is clearly stated at the top; hence, it cannot be equal to a string.
Nov 9 at 13:53 comment added Michael E2 Or[] is not way represent alternative values. It's a logical connective to connect boolean expressions (whose value is presumed to be from the set {True, False}). Since a string does not represent a boolean expression, Mathematica does not know what to do with it and leaves it alone. About the only evaluation one can get is ("a" || "A") == ("A" || "a") since each side is identical. Now Or could connect to equalities, as in Thread[# == ("A" || "a"), Or] & /@ myStrList.
Nov 9 at 13:48 answer added creidhne timeline score: 4
Nov 9 at 13:42 comment added Michael E2 @Nasser's suggestion of AnyTrue[] will "create a function that will return True..." as you say you want. Further, it will return True as soon as it runs into an "a" or an "A", whereas Map[] will pointlessly continue to check all remaining strings.
Nov 9 at 11:28 answer added Domen timeline score: 5
Nov 9 at 11:01 answer added azerbajdzan timeline score: 5
Nov 9 at 2:12 comment added Bob Hanlon Or, ToUpperCase[#] == "A" & /@ myStrList
Nov 9 at 1:59 comment added Syed StringMatchQ["A" | "a"]@myStrList ?
Nov 8 at 22:15 comment added lericr If by "condense" you mean something more like "reduce duplicated constructs", then you could do a variety of things. E.g. test = (Apply[Or]@*Comap[MatchQ /@ {"A", "a"}]). To demonstrate, test["A"] gives True and test["b"] gives False.
Nov 8 at 22:03 comment added lericr If you specifically want Or in your test, then no, I don't think there's a way to condense your test. Or expects to be applied to boolean expressions. The expression Or["A", "a"] is applying Or to strings. The semantic that you're looking for in something like Or["A", "a"] is already provided by Alternatives, which you've already used successfully in another version of your test.
Nov 8 at 21:12 comment added Nasser # == Or["A", "a"] & does not look right to me. The syntax of Or is not like this. But why not just use something like AnyTrue[myStrList,Or[#=="A",#=="a"]&]. I know you said you wanted to use Map. In Mathematica there are many ways to do the same thing. I see nothing wrong with your earlier tries also. But the last one, your Or usage is not correct. You can fix it by doing Or[# == "A", # == "a"] i.e. move the # inside.
Nov 8 at 21:06 history edited Andrew CC BY-SA 4.0
improved formatting
Nov 8 at 21:01 history asked Andrew CC BY-SA 4.0