Reputation
148,367
Next tag badge:
100/100 score
19/20 answers
Badges
18 277 634
Newest
 Enlightened
Impact
~1.7m people reached

16h
comment Is there a practical way to define a default value for missing keys in an Association?
@rcollyer That works in many cases but it prevents the (IMHO) natural use of operators such as Increment or AddTo. I see no reason that a default in the Association and a specified default in Lookup cannot coexist. Am I mistaken?
16h
comment How to sort colors properly?
A pleasing result indeed. By the way I think this is relevant: Is ColorDistance symmetric?
17h
revised Is there a practical way to define a default value for missing keys in an Association?
added 745 characters in body
17h
comment Is there a practical way to define a default value for missing keys in an Association?
This is certainly a valid approach. My issue with it is the extra code needed for every operation; ++asc[#] becoming (KeyExistsQ[#][asc] || (asc[#] = $asc); ++asc[#]) is a pretty bad hit to clean coding. It would be possible to define new operators e.g. associationIncrement (possibly with a shorter name) that handle this but one loses commonality in code. I don't know of any satisfying solution but that is why I posted the question.
1d
comment Is there a practical way to define a default value for missing keys in an Association?
@Leonid Regarding the title I tried to see it from that perspective but I cannot. The default value is not being changed; it is only being used in subsequent computations. Maybe tomorrow I can bring some fresh eyes to it but at the moment it feels like you are critiquing a straw man.
1d
comment Is there a practical way to define a default value for missing keys in an Association?
@Leonid (1) It may be as natural but the functionality exists and I see no reason not to try to use it. I realize that ultimately performance issues may or may not limit use but I disagree that this is somehow an inherent limitation if I infer that correctly. (2) Does the existence of special default handling in Lookup prevent other handling? I wouldn't think so. (3) Do all of the benefits of associations cease to exist for some reason? Easy copying and manipulation of values, nested associations, etc. still apply do they not?
1d
answered Orderless storage of tabulated function values
1d
asked Is there a practical way to define a default value for missing keys in an Association?
1d
comment I need help converting a list into a list of rules for LayeredGraphPlot
I must admit that I do not understand what you wish to visualize.
1d
comment How I can count multiplications in an experssion?
Frankly I don't know. +1 for your interpretation.
1d
awarded  Nice Question
1d
comment I need help converting a list into a list of rules for LayeredGraphPlot
You're welcome, and I am glad I could help. I did not mean to rush you to Accept my answer. (Personally I wait 24 hours before accepting an answer to give everyone a chance to answer first.) I just wondered if I had misunderstood. I imagine you'll find more uses for that simple count method; I know I do.
1d
revised How I can count multiplications in an experssion?
deleted 1 character in body
1d
comment How I can count multiplications in an experssion?
@Andy Thank you.
1d
comment How I can count multiplications in an experssion?
I like the idea of string conversion however this seems baroque. I added what seems like a cleaner alternative to my answer. Does mine fail where yours does not?
1d
revised How I can count multiplications in an experssion?
added 370 characters in body
1d
revised I need help converting a list into a list of rules for LayeredGraphPlot
edited tags
1d
comment I need help converting a list into a list of rules for LayeredGraphPlot
Bob, I see that you have been on-line recently but you did not comment on my answer. Is the output as you desire?
1d
answered How I can count multiplications in an experssion?
1d
comment How to sort colors properly?
Unfortunately this idea runs into a basic problem: You can’t sort colors. Because the human eye has three distinct color sensors (red, green, and blue), color is fundamentally a three-dimensional quantity, and there is no linear ordering that brings together “similar” colors. If you sort first by amount of red, for example, then you may bring together wildly different hues and brightnesses. If you sort by hue, then you bring together wildly different degrees of saturation and brightness, and so on. There’s just no way to do it. -- the article you cite