List of lists elementwise greater/smaller thanElement-wise test on List elementsCombining two listsFast method for combining two listsConditional combining of nested listsHow to use select and map togetherSelect sub-lists of common length from a listCombination of lists elementwiseProducing a list of all the pairs can be made by from two lists of equal lengthCreating lists within lists by sortingComparing elements in a list of listsMultiply two lists
Can we use the verb "says" for advertisement?
You've spoiled/damaged the card
The ring of global sections of a regular scheme
Incremental Ranges!
Working in the USA for living expenses only; allowed on VWP?
Building a road to escape Earth's gravity by making a pyramid on Antartica
What happens to foam insulation board after you pour concrete slab?
I wrote a scene that the majority of my readers loved. How do I get back to that place while writing my new book?
When writing an error prompt, should we end the sentence with a exclamation mark or a dot?
Is there any word or phrase for negative bearing?
what is triplication on fpga?
Word for a small burst of laughter that can't be held back
Side by side histograms
Humans meet a distant alien species. How do they standardize? - Units of Measure
Is it a problem that pull requests are approved without any comments
Is it OK to bring delicacies from hometown as tokens of gratitude for an out-of-town interview?
Why don't B747s start takeoffs with full throttle?
Why is the relationship between frequency and pitch exponential?
Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?
It possible to have subscript and super script that does not shrink the font size?
Is it possible for people to live in the eye of a permanent hypercane?
How to split a string in two substrings of same length using bash?
Riley's, assemble!
Can a magnetic field of an object be stronger than its gravity?
List of lists elementwise greater/smaller than
Element-wise test on List elementsCombining two listsFast method for combining two listsConditional combining of nested listsHow to use select and map togetherSelect sub-lists of common length from a listCombination of lists elementwiseProducing a list of all the pairs can be made by from two lists of equal lengthCreating lists within lists by sortingComparing elements in a list of listsMultiply two lists
$begingroup$
I have two lists
a = 3,1,2,5,1,3,4,1,1
b = 4,0,3,4,2,2,5,0,2
And would like to compare each element within
Ifa>b,1,0
expecting the result
0,1,0,1,0,1,0,1,0
but it doesn't work, how can I get this type of comparison?
list-manipulation map boolean-computation
$endgroup$
add a comment |
$begingroup$
I have two lists
a = 3,1,2,5,1,3,4,1,1
b = 4,0,3,4,2,2,5,0,2
And would like to compare each element within
Ifa>b,1,0
expecting the result
0,1,0,1,0,1,0,1,0
but it doesn't work, how can I get this type of comparison?
list-manipulation map boolean-computation
$endgroup$
1
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
you could use1-UnitStep[b-a]?
$endgroup$
– kglr
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05
add a comment |
$begingroup$
I have two lists
a = 3,1,2,5,1,3,4,1,1
b = 4,0,3,4,2,2,5,0,2
And would like to compare each element within
Ifa>b,1,0
expecting the result
0,1,0,1,0,1,0,1,0
but it doesn't work, how can I get this type of comparison?
list-manipulation map boolean-computation
$endgroup$
I have two lists
a = 3,1,2,5,1,3,4,1,1
b = 4,0,3,4,2,2,5,0,2
And would like to compare each element within
Ifa>b,1,0
expecting the result
0,1,0,1,0,1,0,1,0
but it doesn't work, how can I get this type of comparison?
list-manipulation map boolean-computation
list-manipulation map boolean-computation
edited May 18 at 19:02
Three Diag
asked May 18 at 18:54
Three DiagThree Diag
346111
346111
1
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
you could use1-UnitStep[b-a]?
$endgroup$
– kglr
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05
add a comment |
1
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
you could use1-UnitStep[b-a]?
$endgroup$
– kglr
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05
1
1
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
you could use
1-UnitStep[b-a]?$endgroup$
– kglr
May 18 at 19:02
$begingroup$
you could use
1-UnitStep[b-a]?$endgroup$
– kglr
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Boole@Positive[a-b]
0, 1, 0, 1, 0, 1, 0, 1, 0
1-UnitStep[b-a]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
$begingroup$
kglr took the fast, vectorized operations. Here are some less optimal ones that you can have a look at for fun or for learning:
Boole@MapThread[Greater, a, b, 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
Boole@Apply[Greater, Transpose[a, b, 3, 2, 1], 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198622%2flist-of-lists-elementwise-greater-smaller-than%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Boole@Positive[a-b]
0, 1, 0, 1, 0, 1, 0, 1, 0
1-UnitStep[b-a]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
$begingroup$
Boole@Positive[a-b]
0, 1, 0, 1, 0, 1, 0, 1, 0
1-UnitStep[b-a]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
$begingroup$
Boole@Positive[a-b]
0, 1, 0, 1, 0, 1, 0, 1, 0
1-UnitStep[b-a]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
Boole@Positive[a-b]
0, 1, 0, 1, 0, 1, 0, 1, 0
1-UnitStep[b-a]
0, 1, 0, 1, 0, 1, 0, 1, 0
answered May 18 at 19:06
kglrkglr
195k10216439
195k10216439
add a comment |
add a comment |
$begingroup$
kglr took the fast, vectorized operations. Here are some less optimal ones that you can have a look at for fun or for learning:
Boole@MapThread[Greater, a, b, 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
Boole@Apply[Greater, Transpose[a, b, 3, 2, 1], 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
$begingroup$
kglr took the fast, vectorized operations. Here are some less optimal ones that you can have a look at for fun or for learning:
Boole@MapThread[Greater, a, b, 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
Boole@Apply[Greater, Transpose[a, b, 3, 2, 1], 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
add a comment |
$begingroup$
kglr took the fast, vectorized operations. Here are some less optimal ones that you can have a look at for fun or for learning:
Boole@MapThread[Greater, a, b, 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
Boole@Apply[Greater, Transpose[a, b, 3, 2, 1], 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
$endgroup$
kglr took the fast, vectorized operations. Here are some less optimal ones that you can have a look at for fun or for learning:
Boole@MapThread[Greater, a, b, 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
Boole@Apply[Greater, Transpose[a, b, 3, 2, 1], 2]
0, 1, 0, 1, 0, 1, 0, 1, 0
answered May 18 at 19:13
C. E.C. E.
52.3k3102209
52.3k3102209
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198622%2flist-of-lists-elementwise-greater-smaller-than%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Strongly related
$endgroup$
– Leonid Shifrin
May 18 at 18:57
$begingroup$
you could use
1-UnitStep[b-a]?$endgroup$
– kglr
May 18 at 19:02
$begingroup$
Of course, fixed.
$endgroup$
– Three Diag
May 18 at 19:02
$begingroup$
@kglr yep, that achieves the result, thanks
$endgroup$
– Three Diag
May 18 at 19:05