« first day (393 days earlier)      last day (4092 days later) » 

12:45 AM
Why this no work? :( (#?OddQ) & /@ Range[10]
 
incorrect syntax. Try (# // OddQ) & /@ Range[10]
 
@MikeHoneychurch Thank you mike.
In my old c++, that would be, for(int i=0; i<10; ++i) { myList.push_back( IsOdd(i) ); }
i'm loving functional programming :D
 
OddQ as you know tests for odd. So the syntax is e.g. OddQ[number], OddQ@number, number//OddQ. In other words it is a function. I think with your use of ? you might have been getting mixed up with PatternTest in which OddQ is used to test an element in a list etc.
e.g. Cases[Range[10], _?OddQ]
 
Exactly
 
1:04 AM
Sup rm -rf
 
@AdamDreaver OddQ is Listable, so you can simply do OddQ@Range@10
 
Oooh nice syntax, ty
rm rf is a good name. 4 syllables, I just included that in a freestyle rap
ok, time to go and socialize at work, take guys/gals
 
yes forgot it was Listable
 
2:08 AM
.
 
acl
?
 
bah... the questions we get these days
 
acl
2:23 AM
@rm-rf I couldn't chose which close reason was appropriate for this
choose not chose...
 
I'm told there are some planned changes that will allow mods to close with a custom reason... if and when that comes up, we can close a lot of these with a link to the appropriate doc tutorial page
 
@rm-rf Bad questions these days? I haven't been too active
 
@Rojo You decide :)
 
Haha
 
that link takes me to a 404
 
2:30 AM
It's deleted
 
acl
@MikeHoneychurch probably better this way :)
 
I guess I'll take your word for it. Most questions are asked and answered by the time i log on in the morning but have noticed a deterioration of question quality over the last few weeks. Maybe subjective on my part but my 2 cents
 
acl
(am I really the only one who thinks asking "please plot me the higgs potential" isn't an appropriate question? are we expected to know what the "higgs potential" is now? and anyway it's a 3d plot, just look it up in the docs...)
@MikeHoneychurch no I think that is an accurate observation. that particular question was more or less someone posting some sort of email soliciting job applications
 
Not that my own questions are of broad interest :)
@acl sounds like something that was happening on the linkedin mathematica group last year
 
acl
@MikeHoneychurch I don't think I am a member. but this one was, literally, a copy-and-pasted email
 
2:36 AM
Oh, it's not true that I wasn't active. I just did a long one ;D
Had forgot
Anyway, how are you all doing, people?
@acl 3 close votes already
 
acl
@Rojo I was asking a rhetorical question to encourage others to act :)
 
@acl Well, you did it wrongly, because I answered
 
acl
@Rojo (fine, and you? :) )
 
@acl Haha, I'm good. Watching the Mentalist (I don't like it much but watch it anyway), and probably not going to work tomorrow :)
 
acl
@Rojo sick?
 
2:40 AM
@acl Not at all. I have an unclear arrangement with my boss, that gives me some flexibility
At the end of the day, it's all good as long as the stuff gets done
 
acl
@Rojo murky job situations can be useful
(or "underscpecified" job situations)
 
@acl Exactly :)
 
acl
I am greatly enjoying the Legends functionality, as I am preparing plots for a paper. looking at my plots, I think I ended up putting way too many separate lines just so I could enjoy adding legends...
now we just need undo
 
@acl The first days after v9 was released I read complaints here, but I found it great. In any case I'm no purist with visuals
Hehe
 
acl
@Rojo no they just need to be presentable. legends, as they currently are, are fine for me. but I have low standards
 
2:44 AM
@Rojo Every release will change something that annoys someone
 
acl
@Rojo ha
 
@rm-rf The issue I've had with legends was that i've used them everywhere, but still share with people with v8
So I had to do an ugly If[$VersionNumber<9, Legended[#, "blablablabla"]... etc
in dynamic
several times
 
acl
@rm-rf but 9.0 is teeming with front-end bugs...
 
But its stronger than me, I like to use the new stuff even when it isn't needed
 
acl
2:46 AM
I also use 9 even though, at the moment, copying to the clipboard causes a beep and stuff to be spat out to the console
 
Uh... that doesn't happen here
 
Weird
Not here
 
acl
and I use the clipboard to simulate undo, so...
 
lol
 
acl
@rm-rf @rojo I contacted support, they also couldn't work it out
 
2:48 AM
It's very high on my todo list but I never actually got to try the undo posted as an answer to my highly voted question
Did you? @rm-rf, @acl
 
Nope
 
Hiya!
 
I didn't read it fully, but from what I remember, I think it was more like a version control than a proper undo
@belisarius Hi!
 
@belisarius Ola
 
already complaining about v9?
@Rojo manola
 
2:50 AM
@belisarius If MrWizard asks what you meant, you'll explain
 
@Rojo Is Mr. still on V 5.2?
 
@belisarius I think he is
 
good! 5.2 is very stable
 
Interesting that the king of the site is 2 versions behind
@belisarius Oh, sorry, I had Unprotect[Dot];Dot=Plus
 
@Rojo You're so clever that makes me cry
 
acl
2:53 AM
@Rojo not really
@belisarius yes it's painful
 
@acl I thought it was an intimate feeling. Mmmm ... perhaps his cleverness arises telepathic abilities.
 
Hahah
 
3:33 AM
@rm-rf He's a genius :)
 
 
2 hours later…
5:28 AM
I've never worked with a language that uses pattern matching. I can see how powerful it is, but it's a little overwhelming for me :D Different levels and deliminating the head and all that.
 
5:47 AM
oh well, i'm putting in the time and I'm now starting to get it. I look forward to when I can use Position/Extract in some useful way.
dude is using project euler to learn mma. so smart.
2
Q: Improve performance and style of solution to Project Euler #32

RunnyKineSince I'm fairly new to Mathematica, I'm trying to learn better ways to improve my coding skills so I've turned to Project Euler and this site to speed up my learning pace. Anyways, I was trying to solve problem 32 on the project Euler forum and came up with the following code PanDigital[n_, m_]...

 
 
6 hours later…
11:47 AM
Hello, I'm looking for some undocumented method to replace the whole expression with ReplacePart, something like
ReplacePart["S", All -> "A"]
which unfortunately returns "S" instead of "A". I am inclined to believe that ReplacePart cannot do this.
 
12:00 PM
Unprotect[ReplacePart]
ReplacePart[x_, All -> y_] := Replace[x, _ -> y]
Protect[ReplacePart]
 
12:21 PM
@Xerxes Thanks @Xerxes but I am looking for a solution that is internal to ReplacePart.
If there is any...
 
@IstvánZachar Hey, why do you want that?
 
@Rojo I have a function that replaces parts of an expression (via ReplacePart) that are found by using Position. Now Position returns {} if the whole of the expression matches the pattern, but ReplacePart cannot deal with such a position specification.
So I have to do such external gymnastics as the one Xerxes has suggested.
See this toy example:

expr = f[f[f[]]];
rule = f[x___] :> g[x];
pos = Reverse@Position[expr, First@rule]
ReplacePart[expr, # -> g[]] & /@ pos
 
I see
 
It seems reasonable that ReplacePart should deal with {}, but actually it can not.
 
Agree
@IstvánZachar This is disgusting, but another option may be to parse the rules
rpRule = (Rule | RuleDelayed)[{},
rhs_] :> (_ /; Return[rhs, ReplacePart] :> Null)
and then
ReplacePart["S"[2], ({} :> "A") /. rpRule]
ReplacePart["S"[2], ({1} :> "A") /. rpRule]
Less intrusive than unprotecting
 
12:45 PM
Well, I have two concerns with this:
1. one can use pos.specification 0 to replace heads in ReplacePart
2. this still won't replace: ReplacePart["S", ({} :> "A") /. rpRule]
Anyway, if there is no internal method for this, I guess I will just use simple forking:

If[# === {}, use Replace, use ReplacePart] &/@ positions
 
Yeah, you're right
 
Thanks anyway for the help!
 
1:05 PM
@IstvánZachar maybe something like this
myRules /: ReplacePart[expr_, myRules[Except[_List, rspec_]]] :=
  ReplacePart[expr, myRules[{rspec}]];
myRules /: ReplacePart[expr_, myRules[{{}~(Rule | RuleDelayed)~rep_}]] :=
  rep;
myRules /: ReplacePart[expr_, myRules[rspec_]] :=
  ReplacePart[expr, rspec];
expr = f[f[f[]]];
rule = f[x___] :> g[x];
pos = Reverse@Position[expr, First@rule]
ReplacePart[expr, myRules[# -> g[]]] & /@ pos
(* -> {{}, {1}, {1, 1}} *)

(* -> {g[], f[g[]], f[f[g[]]]} *)
 
Quite complicated, but it works : )
 
Perhaps changing the second definition to allow for any number of rules?
myRules /: ReplacePart[expr_, myRules[{___,{}~(Rule | RuleDelayed)~rep_,___}]] :=
rep;
 
@Rojo yes, many improvements are possible. Since the total replacement overrides everything else I didn't think it was meaningful to have it combined with other rules so I deliberately didn't address that case.
Handling of options would also need to be added. I doubt if I would use this approach myself but @István seems wedded to using ReplacePart for what I assume are good reasons.
 
If you are interested, I can make it a proper question so that you can post your answers.
It would give room for further improvements
 
1:21 PM
I don't mind. Do it if it would be helpful to you but I don't think either of these "answers" is really anything to be proud of
 
@IstvánZachar If so, you will have to be more specific as to what you are trying to achieve
 
@Rojo Sure, I have a very specific problem. If I'll have time later today, I'll try to write it up properly.
 
@OleksandrR. Hey, perhaps you konw how to handle these issues
I have a continuous piecewise function that has a discontinuous derivative, that I use in NDSolve, and get errors for its Indeterminate derivative
 
@Rojo sorry, I don't. :) I've never used NDSolve seriously. It's on my list to learn about it.
Ugh, doc center freezes
@Rojo tutorial/NDSolveWhenEvents#1688891301 ?
 
1:40 PM
@OleksandrR. Let's see, seems promising, thanks
 
 
1 hour later…
3:04 PM
Hum... Does anybody have any idea why I can't seem to Compile my function defined as
veryManualFunction[] := (pos = 1; weights = {1, 1, 1};
Do[choiceWeights = weights; choiceWeights[[pos]] = 0;
newPos = RandomChoice[choiceWeights -> {1, 2, 3}];
edgeNumber = {1, 3, 0, 0, 2}[[-2 +
newPos + (-1 + newPos) (-1 + pos) + pos]];
weights[[edgeNumber]] = weights[[edgeNumber]] + 1;
pos = newPos, {1000}]; weights)
 
3:15 PM
Note that
compiledChoice =
Compile[{{x, _Integer}}, RandomChoice[{4, 5, x} -> {1, 2, 3}]]
Does work... CompilePrint gives that it does something nontrivial, rather than just doing MainEvaluate
 
@JacobAkkerboom You probably have to localize all the variables you use. Try Block[{pos=1,...},...].
 
Ah, thanks
So I put the Block outside the Compile ?
or inside I guess
Hmm... Still no luck :(
 
@JacobAkkerboom post the Compile
 
hi @halirutan, did you see my comment on the mathlink/librarylink question?
 
I'm basically doing this
Compile[{},
Module[{pos = 1, weights = {1, 1, 1}, choiceWeights, newPos,
edgeNumber},
Do[choiceWeights = weights; choiceWeights[[pos]] = 0;
newPos = RandomChoice[choiceWeights -> {1, 2, 3}];
edgeNumber = {1, 3, 0, 0, 2}[[-2 +
newPos + (-1 + newPos) (-1 + pos) + pos]];
weights[[edgeNumber]] = weights[[edgeNumber]] + 1;
pos = newPos, {1000}]; weights]]
Huh
that works!? :D
@Rojo, @Ajasja tnx!
Yeah, making one variable not local introduces a bunch of uses of MainEvaluate. That makes sense..
 
3:55 PM
I voted close as too localized on this one, as there's not enough info to reproduce and the OP hasn't written back.
 
@Szabolcs yup
 
@Szabolcs I saw them, yes, but had no time to answer appropriately. Therefore, I left it until I have a bit time to think about it.
 
4:46 PM
0
Q: How do you reward two good answers?

zentientI posed a question and received two good answers. I'd like to 'accept' both, but this appears impossible (likely for good reasons). Must I just choose one (after voting both up), or can I accept/reward/honor both answers in some way? The context is: I posed this question which (I humbly believe)...

 
 
3 hours later…
7:32 PM
I voted close on this one too because of Jens's (correct) comment. I'm not sure others agree this should be closed, but I don't see a reason to post an answer. It's not of help to future visitors, it's a math mistake.
 
 
1 hour later…
8:59 PM
posted on February 14, 2013 by Giulio Alessandrini

Mathematica 9 has just been released with many new or enhanced capabilities for image processing. You can perform morphological operations, color manipulation, segmentation analysis, feature detection, and more, most of which can be applied to the new Image3D object as well. A byproduct of this whole ecosystem is that now it is easier than ever [...]

 
9:37 PM
The fire filter is a per pixel filter that averages pixels over time from a set of "hot" pixels choosen at the bottom of the screen. I wonder if there's a way to replicate that famous demo program in mathematica? I'm so weak on animations and real time graphic capabilities of mma. I don't want the code for this demo, I just want to know, is it possible?
the hot pixels are randomly lit every few dozen ms or so.
 
 
1 hour later…
11:01 PM
ParametricPlot[{
{Sin[Pi t] + Cos[Pi t] + 1, Sin[Pi t] - Cos[Pi t]},
{-Sin[Pi t] - Cos[Pi t] - 1, Sin[Pi t] - Cos[Pi t]},
{2 (1 - t), -(2 t + 1)},
{-2 (1 - t), -(2 t + 1)}
}, {t, 0, 1}, Axes -> False, PlotStyle -> {Red}]
Sorry if there've been a lot of those today :-)
 
11:19 PM
I bet that's gonna be a heart :D
@robjohn Happy valentine's day robjohn
 
11:30 PM
@AdamDreaver and to you, too
@AdamDreaver At least here I can be pretty sure that everyone can render it. On math.SE, I had to post a rendering, as well.
 
I'm trying ot make it 3d right now
now I give up, I realize I have no idear how to make a 2d parametric plot into a 3d parametric
 
@AdamDreaver It is hard because the two circles (spheres) need to lose the crease part way down the heart.
 
11:49 PM
@AdamDreaver @robjohn:
ContourPlot3D[(x^2 + 9/4 y^2 + z^2 - 1)^3 - x^2 z^3 - 9/80 y^2 z^3 == 0,
    {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, ContourStyle -> Red, Mesh -> False, PlotPoints -> 100]
 
@rm-rf oh wow, VERY NICE!
 

« first day (393 days earlier)      last day (4092 days later) »