Skip to main content
8 events
when toggle format what by license comment
Apr 13, 2017 at 12:55 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Mar 30, 2013 at 1:34 comment added kurush Yes, that's the part of my code MapThread[If[#1 < max && #2 > min, {#1 + 1, #2 - 1}, {#1, #2}] &,Transpose@lst2]. If the elements are outside the interval defined by [min,max] then the program returns the default value. And yes, they are always integers. In my version using your suggestions this part stayed untouched.
Mar 29, 2013 at 18:22 comment added Mr.Wizard @kurush Sorry, I somehow didn't see the update to your question until I noticed the Accept. (Thanks.) Let me see if I understand this right: if the additions or subtractions on any specific element would cause it to be outside the interval [0, 2] the original value should be used instead. Is that correct? Are you inputs always integer valued lists? If so we can efficiently use Clip. Let me know and I'll update my answer either way.
Mar 29, 2013 at 15:37 vote accept kurush
Mar 29, 2013 at 15:37 comment added kurush Well, thanks. Your suggestions really improved the performance of my code.
Mar 26, 2013 at 13:14 comment added kurush Thanks for your answer. In the original post I already put a better explanation of the second part of the question. However, is there some way to put constraints in the values of the lists elements? If you have {...a+1,b-1...} exclude results if a is greater than a certain value (say 2) or if b is less than a certain value (say 0)?
Mar 26, 2013 at 6:13 history edited Mr.Wizard CC BY-SA 3.0
added 353 characters in body
Mar 26, 2013 at 5:41 history answered Mr.Wizard CC BY-SA 3.0