57,192 reputation
5161254
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 37
visits member for 2 years, 7 months
seen 1 min ago

Ok, an obligatory note: opinions expressed here are mine and not those of my employer.


Dec
18
comment Any built-in function to generate successive sublists from a list?
@rcollyer I did not benchmark (FoldList), but I don't expect them (differences) to be very significant.
Dec
18
comment Any built-in function to generate successive sublists from a list?
@rcollyer I don't consider myself good at them either, just OK. The problem is that Mathematica's execution model often creates rather unnatural preferences for the algorithms implementations. But recursion is very powerful. Actually, I don't know what I would do without it for many problems. It was very important ingredient for RLink, for one thing.
Dec
18
comment Any built-in function to generate successive sublists from a list?
I think @kguler's use of ReplaceList is very elegant. For generic lists, should be quite fast. For packed arrays, Join and Append should be faster, since ReplaceList can not make use of those and will likely unpack.
Dec
18
comment Any built-in function to generate successive sublists from a list?
I think that most of us like list manipulation because M has an outstanding support for them, so that our programming flow can be very smooth. For a number of other things (handling state, implementing data structures with certain characteristics, scaling codebase to larger size, etc), the support is perhaps not so great, so one has to overcome significant mental barriers and these topics are less attractive to most M users. But this is what interests me more at present, since this is what stands in my way.
Dec
18
comment Any built-in function to generate successive sublists from a list?
Actually, @rcollyer posted it, so problem solved :). Re: gold badge - I've got one already, on SO :). Seriously, I am much less interested in list manipulations in Mathematica now than I used to be. I found that things that make it hard for me personally to code in M are mostly elsewhere (and it is not always obvious what they are, for a given problem).
Dec
18
comment Any built-in function to generate successive sublists from a list?
Ok, since you posted this, I am liberated from doing that (I gave it in comments to the question), and can happily upvote : +1.
Dec
18
comment Any built-in function to generate successive sublists from a list?
@rm-rf Somehow I did not expect so much excitement about this topic, so many answers. I could as well post it indeed. Perhaps I will. But my solution suffers from the same flaw as others.
Dec
18
comment Any built-in function to generate successive sublists from a list?
@rcollyer Be careful with MapAt though.
Dec
18
comment Any built-in function to generate successive sublists from a list?
+1. But the real clean solution here is to use linked lists, since all of the suggested ones have quadratic complexity in the length of the list.
Dec
18
comment Any built-in function to generate successive sublists from a list?
How about something like Rest@FoldList[Append, {}, {a, b, c, d}]? More succinctly, FoldList[Append,{First@#},Rest[#]]&[{a,b,c,d}]
Dec
17
comment Break[] inside ColorFunction
This also has to do with the anonymous functions, since Plot[x, {x, 0, 1}, ColorFunction -> (Function[c, ColorData["Rainbow"][f[c]]])] works fine. Perhaps, @Rojo is right, and it tries some destructuring of the function and isn't careful enough about it.
Dec
17
comment Syntax highlighting for your own functions
@AndreasLauschke Thanks:) But it actually has to be rewritten. It has a number of design issues which I hope to address soon enough. In many places, the code is pretty ugly to my taste, also.
Dec
17
awarded  pattern-matching
Dec
16
comment Different behaviour of ValueQ inside and outside of a loop
Somewhat related question
Dec
14
comment Sorting function for non commuting bosons
@Karan Good that you managed. In general, such problems are expected. If you want to make it rather general-purpose, you have to add more rules.
Dec
14
comment Sorting function for non commuting bosons
@Karan I don't have much time now, but Times sometimes evaluates, so you often need HoldPattern. I also did not include Times in the rule, that's why your input does not evaluate.
Dec
14
comment Reloading package after accidental Remove[] of symbol
Note that reloading a package in such a case is a necessary but often not sufficient measure in such situations. In particular, if there are symbols defined in Mathematica session (in other packages that use that one or otherwise) which refer to the symbol you removed, you have to reload those packages / definitions as well. The problem is made worse by the fact that there are no warnings, neither when you remove the symbol, nor later when you call those functions. Their definitions simply become invalid. And the re-introduction of the symbol into Mathematica session does not help it.
Dec
14
comment Sorting function for non commuting bosons
@Karan See the edited version. Try to understand the logic here, this part with c-numbers was not hard at all.
Dec
14
revised Sorting function for non commuting bosons
Added c-number treatment
Dec
13
comment Sorting function for non commuting bosons
@Jens Thanks, edited.