91,121 reputation
15156390
bio website
location Oregon, USA
age
visits member for 2 years, 3 months
seen 1 hour ago

Happy New Year!


(also known as Spartacus)

Project Euler


See those two pins? Well today I'm going to... stick them in you.

Ok, let me come clean: Mr.Wizard is actually an alias of mine... I'm glad I can finally confess. ― Sjoerd C. de Vries

No, I'm Spatac... I mean, Mr.Wizard! ― R.M

I'm Mr.W, and so's my wife! ― acl


@Spartacus, it was not fixable. ― rcollyer

check again; I just fixed it. :-p ― Spartacus


"This is the internet, where the men are men, the women are men and the children are FBI agents..." ― yoda Dec 18 '11 at 6:06


"My main purpose of being here is in collecting the votes. I'd even go further and say that this is my main purpose in life." ― Leonid Shifrin


"I am making some voodoo dance and invoking the rain God while we talk" ― belisarius


Some people are fortunate. Others get married. ― belisarius


It's not that easy to do the untangling even manually though. – Szabolcs

Maybe you could turn it into a puzzle and let other people do the untangling :-) – Heike

I could make a web based game, and feed all my graphs to the visitors.
SE is a big game, isn't it? :D – Szabolcs


"ListContourPlot crush on simple 5-points data" (Question title)

"Yes, this must be love at first sight."ruebenko


... but I am working with a large body of code written by an incompetent fool (i.e. myself, several years ago...) – Simon Woods


I was tempted to edit your title: "Do rules rule?" But my nose is still bleeding as a result of a limerick. – belisarius



1h
comment Map structure of irregular list, Flatten then reconstruct list using structure
As far as I know you can't dynamically reshape arrays within a single CompiledFunction block without losing (some of?) the advantage of compiling. I am wondering if instead it is possible to create a series of separate compiled functions, perhaps dynamically generated (meta-programming), then pass the data from one to another. I am surely not an expert on compilation so I'm not sure if there is any merit to this idea (e.g. overhead may be significant) but is one possible approach.
5h
comment Define a function that takes ragged array
@Ply_py To complete my suggestion into your step function you would write: step[fun_] := # /. {var_, itr_} :> {fun[var], itr + 1} &; -- now step[foo][{{1, 2, 3}, bar}] yields {foo[{1, 2, 3}], 1 + bar}. More complicated "destructuring" is possible with this method.
5h
comment Define a function that takes ragged array
@Ply_py You're welcome. Mathematica is complex and even figuring out the right question to ask can be difficult. Since you have your solution let's leave this question as it is. Using Part (the method you Accepted) is perfectly fine, and one that is frequently used. However be aware that it can also go wrong as there is no "type checking" of the input; Part will simply try to extract those parts of any expression it is given. I think you can learn a lot from a careful reading of the Q&A I linked earlier, but perhaps you are not quite ready for them. (continued)
5h
comment A problem with set values
@Shellp I'll try to get around to this in a few hours.
6h
comment String formatting
I see your logic. In that case I suggest strict use of regular expressions unmixed with Mathematica patterns; this would also simplify syntax. One could write e.g. regexReplace[string_, rules_, n_: Infinity] := StringReplace[string, #, n] &[ rules /. (L_ -> R_) | (L_ :> R_) :> (RegularExpression[L] :> R) ] and then perform this manipulation with regexReplace[str, {"," -> "", " \\( +" -> ",(", "\\) +" -> "),", " +" -> ","}]. What do you think of that proposal?
20h
comment Define a function that takes ragged array
I missed your question. I think it is simply an expression that conforms to a particular pattern, but I don't claim any authority on such terminology.
20h
comment Define a function that takes ragged array
I acknowledge the arrogance (possible hubris) of this, but if you did not find those posts helpful I do not believe you understood them. I still don't understand your example since the function (first parameter) in Fold takes two arguments, not one. Nevertheless I suspect you want something like this: fn = # /. {var_, itr_} :> {fun[var], itr + 1} & then fn[{{1, 2, 3}, 1}] yields: {fun[{1, 2, 3}], 2}. If this is not what you want please try again to make us understand.
21h
comment A problem with set values
@Shellp Please don't take offense at what I am about to say, because Mathematica is really quite unlike most other languages. You are at a rudimentary stage of Mathematica programming, and I am seeking a way to at least illustrate a better style in which to implement your algorithm. If you are able to give a larger example of what you wish a specific function to accomplish (and the sooner you start thinking in terms of functions the better, re: Mathematica), I shall try. For now this recent post by WReach would be a good start.
21h
comment Define a function that takes ragged array
No, that's not a ragged array either, at least not in the typical usage. (Usually it refers to an array with rows or columns of unequal length, e.g. {{1}, {2, 3}, {4, 5, 6}}.) I'm pretty sure this question is going to turn out to be a duplicate of Mathematica Destructuring or possibly Is there any way to define pure functions with optional arguments? Please take a look at those Q&A's and let me know if your question is answered.
22h
comment A problem with functions and Infinite expression 1/0 encountering
I see that you Accepted my answer there. Thanks (really), but I am still hoping for the opportunity to show you "a better way." I will you describe what you want that code to accomplish? That is, what is your "real problem?"
22h
comment Define a function that takes ragged array
I read this question but I did not understand it. What exactly do you mean by "ragged list?" I am familiar with the term ragged array, but you do not seem to mean that. Would you please give a complete example of the exact input and output that you want from your function?
22h
comment A problem with functions and Infinite expression 1/0 encountering
I wish to help, but I would like to address your questions in the order they appeared. Will you please reply to my requests in my answer to A problem with set values first?
1d
comment Splitting a list into list of lists
For advanced variations that are not built in see Partitioning with varying partition size and On generalizing Partition (with offsets) to sublists of unequal length. Also potentially non-obvious: Using Partition to allow sublists of different lengths
1d
comment How to get mathematica to simplify a result
FYI: I wasn't doubting your veracity, rather such things often need to be localized to which versions they affect to best address them. Thanks.
1d
awarded  Popular Question
1d
comment How to get mathematica to simplify a result
In version 7 FullSimplify[PolyLog[2, 3 - 2 Sqrt[2]] - 4 PolyLog[2, -1 + Sqrt[2]]] outputs -(Pi^2/4) + Log[1 + Sqrt[2]]^2, which is I believe what you want. Which version are you using?
1d
revised Scan vs Map vs Apply
added 20 characters in body
1d
comment Undocumented form for `Extract`
Sorry, I missed your comment until after you posted this. This structure is OK, but personally I would have used something like: "Is it possible to use Span in Extract?" -- "Yes, since at least v9 there is an undocumented syntax for this, and it performs very well..." You can rewrite your Q&A like that if you wish, or leave it as it is; either way it gets the information out to people. +1 :-)
1d
comment A problem with functions and Infinite expression 1/0 encountering
Also, FYI: CosInt * BoxMatrix[0, 6] // MatrixForm
1d
comment A problem with functions and Infinite expression 1/0 encountering
Related, I believe: What is the cleanest way to prevent divide-by-zero warnings?