Reputation
80,218
Next tag badge:
288/100 score
18/20 answers
Badges
8 235 330
Newest
 Good Answer
Impact
~556k people reached

May
2
comment how to apply Alternatives command to delete cases from a list?
You could use something like DeleteCases[newD, Alternatives@@Join[listF, Reverse[listF, {2}]]] (untested).
May
1
comment Is there any harm or benefit to Removing unneeded private symbols in packages?
Nothing to add to this, really. A great answer. +1.
May
1
comment Is there any harm or benefit to Removing unneeded private symbols in packages?
I would never do it, even with my own packages. You may break the package in very subtle ways, while the benefits are very questionable. I agree with others who suggested against it, particularly R.M. gave a great answer. I just wanted to emphasize that IMO one shouldn't do this, period.
Apr
28
comment How to make a replacement, provided an inner rule applies
Looks like a valid alternative. Personally I try to avoid side effects, but this particular code looks fine to me.
Apr
24
comment Core functions or operations that every aspiring Mathematica programmer should know?
Strange. I left a comment here after the question was asked, and don't remember deleting it, however it is no longer here.
Apr
23
comment Looking for “Longest Common Substring” solution
@RunnyKine Sounds good!
Apr
23
comment Looking for “Longest Common Substring” solution
@RunnyKine I guess it should be possible, and not too hard. I don't know C#, but I might be interested in writing such a reloader. Will add that to my project list. Problem is, I have lots of things there already, so can't say when I get time to look into it. You could try yourself, and actually, I've read somewhere that in C#, you can access compiler via an API, rather than command line, so this can be even simpler. Basically, all you'll need is to find a C# analogue of Java class path, so that you could add compiled C# class(es) and they will then be loaded.
Apr
19
comment How to match Association[]?
Use Verbatim, as @RunnyKine suggested. Since it does not prevent evaluation of parts of the pattern, you will then compare evaluated / constructed Association[] in your expression with a similarly evaluated Association[] inside the pattern. Or, much simpler, if you don't care whether or not association is empty, you could use _Association pattern, which is matched in both cases.
Apr
19
comment How to match Association[]?
The subtle point here is that Association[] evaluates to <||>, and even though the FullForms of the two are the same, SameQ on them gives False, because the constructor Association[] does a non-trivial job when evaluated, and the result of it is not a normal expression Association[], but a new atomic object. So, we have Unevaluated[Association[]] === Association[] producing False. Therefore, MatchQ[Association[], HoldPattern[Association[]]] gives False, while of course MatchQ[Association[], HoldPattern[Evaluate@Association[]]] gives True.
Apr
19
comment Is there research about the Mathematica programming paradigm?
@kirma Somehow I have a feeling that if the language only has interpreter(s), that isn't good enough in this context (PL research, and such). I thought about Python too, and it really doesn't compare to Haskell, ML / OCaml, Lisp / Scheme, or even C, in terms of PL research availability for it, although Python's situation is definitely much better than WL's. The PyPy folks had to introduce their own Python subset which can be statically compiled, and they have JIT, which is not quite the same as ahead of time compiler. And it's not just about being dynamic - Scheme and Lisp are dynamic too.
Apr
18
comment Is there research about the Mathematica programming paradigm?
Somehow, I have a feeling that there is a strong correlation between the volume of research and the availability of at least one compiler for a full language, for the mainstream languages at least. This is probably another way to say what @kirma stated, because availability of the compiler implies certain degree of rigor in the language spec. Also, this seems to be a necessary but not sufficient condition - there are certainly languages which have compilers but aren't so fascinating to do research about (my gut feeling is that C++ can be an example here).
Apr
18
comment How to setup logging levels?
A cheap way would've been to use log4J via JLink. Here is a relevant discussion.
Apr
17
comment A question regarding shadowed symbols
Not sure what you mean. You can either run the code from the FrontEnd, or inside the package, or from a text interface. In each case, the result depends on how the code is parsed and executed. I don't remember off hand the package and text-interface case, but chances are you'd get the same behavior there as well, given that With and everything inside it is a single expression, and so should be parsed entirely before execution. It may however be not the case if e.g. the package parser works differently. I don't have the time to test now, but it isn't hard.
Apr
17
comment A question regarding shadowed symbols
This is a problem with the parsing in FrontEnd, not scoping. For the lines on the top-level, FE parses and executes them one by one, sending them as separate evaluations to the kernel. If you enclose code in some wrapper (With, in your case), all the code inside is parsed as a whole, and so in your second case you create a global symbol at the parsing stage, even before your package gets loaded - and so you get the shadowing. See this discussion for a similar issue.
Apr
7
comment Loose binding of &
The pattern simply does not match for h, because, as you noted, the precedence of & is very low. In particular, funct_: (##) & // FullForm will give you Function[Optional[Pattern[funct,Blank[]],SlotSequence[1]]], which is not what you want.
Apr
6
comment Logical AND of multiple patterns
Sure, that's trivial to do: AndPattern[patts___] := Except[Alternatives @@ Map[Except, {patts}]]. Then it looks more pleasant: Cases[input, AndPattern[{___, a, b, ___}, {___, b, c, ___}]]. I don't know a better way for this problem. OTOH, frankly, I never needed it. Whether it really means that such cases are rare in practice, or is a Sapir-Whorf phenomena at work, I can't say.
Apr
6
comment Logical AND of multiple patterns
It is somewhat ugly, but you can use something like this: Cases[input, Except[Except[{___, a, b, ___}] | Except[{___, b, c, ___}]]]
Apr
3
comment How to prevent substitution in a part of an expression?
@Felix Was glad to help. Thanks for the accept.
Mar
30
comment Why is an empty list not tested by VectorQ?
Great answer, very well articulated. I am glad I did not write my own. +1.
Mar
29
comment How to parse a clojure expression?
This is impressive. +1, of course.