4.22 Tuesday, July 25, 2017

================================== 
Top new questions this week: 
==================================

[Reduce Code Length] https://mathematica.stackexchange.com/questions/152003/reduce-code-length

I have the following that works good, and computes in one shot,but the code is so long. Can someone please help me to reduce the size of this?

...

- asked by Bill W. (9 votes), answered by Ali Hashmi (7 votes)

—————————-

[Best way to handle nested Maps?] https://mathematica.stackexchange.com/questions/151742/best-way-to-handle-nested-maps

I often find myself working with lists of lists of data, gathering data, performing computations, and producing a variety of different sorts of output. Intuitively, it seems like this should be done ...

- asked by Michael Stern (9 votes), answered by eldo (6 votes)

—————————-

[Color gradient varying in a path] https://mathematica.stackexchange.com/questions/151980/color-gradient-varying-in-a-path

The code below is to create something like a logo. I want to apply a color gradient over the polygons of the pattern, but they vary along the path. The image that I want to approach is this:

ang = ...

- asked by LCarvalho (8 votes), answered by KennyColnago (9 votes)

—————————-

[Offset Partition with only one remainder element] https://mathematica.stackexchange.com/questions/152152/offset-partition-with-only-one-remainder-element

I would like to use a combination of options of Partition in a way that I can’t seem to find in the documentation.

Given example input {a,b,c,d,e,f,g}, I would like output  ...

- asked by George Moore (7 votes), answered by kglr (4 votes)

—————————-

[Slot # corresponding to subset of a list in select] https://mathematica.stackexchange.com/questions/152082/slot-corresponding-to-subset-of-a-list-in-select

Is it possible to use # in the select function preserving the structure of the list? 
 
Here an example of what I mean. Let's say I want to select all the pairs 
where the first element is 1: 
 
data1 =  ...

- asked by Fraccalo (7 votes), answered by kglr (7 votes)

—————————-

[Any faster approach than Outer for my computation] https://mathematica.stackexchange.com/questions/151892/any-faster-approach-than-outer-for-my-computation

Outer is slowing down considerably when the first argument is Abs[#1 - #2]/Max[#1, #2]& 
 
Outer[List, Range[5000], Range[5000]]; // AbsoluteTiming 
(* {0.120091, Null} *) 
 
Outer[Abs[#1 -  ...

- asked by Ali Hashmi (6 votes), answered by nikie (9 votes)

—————————-

[How to generate password] https://mathematica.stackexchange.com/questions/151864/how-to-generate-password

I would like to generate a random password of a defined length which can easily be typed in with a standard keyboard.

As a start I tried the following:

SeedRandom["pass"]; 
 ...

- asked by mrz (6 votes), answered by yohbs (11 votes)

================================== Greatest hits from previous weeks: ==================================

[Why should I avoid the For loop in Mathematica?] https://mathematica.stackexchange.com/questions/134609/why-should-i-avoid-the-for-loop-in-mathematica

Some people advise against the use of For loops in Mathematica. Why? Should I heed this advice? What is wrong with For? What should I use instead?

- asked by Szabolcs (52 votes), answered by Szabolcs (62 votes)

—————————-

[Why round to even integers?] https://mathematica.stackexchange.com/questions/2116/why-round-to-even-integers

According to the Mathematica help:

Round rounds numbers of the form x.5 toward the nearest even integer.

For example:

Round[{0.5, 1.5, 2.5, 3.5, 4.5}] 
 
 
gives 
 
{0, 2, 2, 4, 4} 

- asked by wxffles (64 votes), answered by Per Alexandersson (42 votes)

================================== Can you answer these? ==================================

[How can I exclude factors containing a certain symbol form matching my pattern] https://mathematica.stackexchange.com/questions/151971/how-can-i-exclude-factors-containing-a-certain-symbol-form-matching-my-pattern

Ok, I give up. I can’t figure how to tell Mathematica to do replacement using a pattern except for some special case. Easier to explain with small example.

I want to change  pattern Exp[any_. c] to c  ...

- asked by Nasser (3 votes)

—————————-

[Graphics3D with explicit ViewAngle inside Manipulate disappears for a moment when starting rotation] https://mathematica.stackexchange.com/questions/151978/graphics3d-with-explicit-viewangle-inside-manipulate-disappears-for-a-moment-whe

Given the following:

Manipulate[ 
    ContourPlot3D[ 
        x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)^2 + 3 (x^2 + y^2 + z^2) == 3 c, 
        {x, -3, 3}, 
        {y, -3, 3}, 
        {z, -3, 3}, 
         ...

- asked by Mark (1 vote)

—————————-

[MTensor from existing memory?] https://mathematica.stackexchange.com/questions/151780/mtensor-from-existing-memory

I am wondering whether it’s possible to return a tensor from my C++ code using LibraryLink without copying the memory (because it’s large). So, instead of

libData->MTensor_new(..., &T0); 
 ...

- asked by mrupp (2 votes)