Reputation
Next tag badge:
283/100 score
18/20 answers
Badges
8 227 319
Newest
 Enlightened
Impact
~511k people reached

Jan
4
comment Check an Option without Evaluation
Thanks! Re - email: I have added it to my profile, you will have to Uncompress the string.
Jan
4
comment Check an Option without Evaluation
The first one leaves results as strings, while the second version gives you a list of already parsed options (as a single Mathematica expression). Re - understand - well, you will have to go down this road some distance anyway, if you have to seriously use Mathematica. What better time than the present? :)
Jan
4
comment Check an Option without Evaluation
Or, if you want the kept options in already parsed form (which you probably do), you can use e.g. this code: Cases[Map[ToExpression[#, StandardForm, HoldComplete] &, StringSplit[text, "\n"]], HoldComplete[opt_ /; OptionQ[Unevaluated[opt]]] :> opt].
Jan
4
comment Check an Option without Evaluation
Well, of course OptionQ gives False on an expression with the HoldComplete head. What you may need is slightly more complex, I just suggested the main idea of the solution. The actual code you may need can be something like Select[ StringSplit[text, "\n"], ToExpression[#, StandardForm, Function[expr, OptionQ[Unevaluated[expr]], HoldAllComplete]] &].
Jan
4
comment Check an Option without Evaluation
You can use ToExpression with 3 arguments, for example like ToExpression[codestring, StandardForm, HoldComplete], in which case the code will be parsed but not executed, and will be returned to you wrapped in HoldComplete. You can then analyze the code without evaluating it.
Jan
4
comment How to compile effectively?
@matheorem IIRC, it has to do with coersing a tensor to a given type, e.g. reals or complex numbers. It is better if it is also avoided, but I don't think it occurs as often as CopyTensor. Besides, these instructions are typically more harmful when they occur in some loop, than when they happen just a few times in the program.
Jan
4
comment Generating assignments and transforming code inside Holding forms when generating code
@ManuelOdendahl Don't take is seriously, I was just kidding :). Actually, a good practice when asking / accepting a best answer is to give answerers some time (like half a day, a day or two) to answer before marking some answer as accepted, even if you have some really good answers already - because that would encourage others to contribute. But this is entirely up to the asker, and you can of course accept the answer you like any time you want.
Jan
4
comment Generating assignments and transforming code inside Holding forms when generating code
Yes, agree on all points. Thanks for replying. Actually, while I experimented with this technique, I may have overlooked its usefulness. In particular, I like the composability of your approach. When at some point I needed similar functionality, I ended up using Block-based technique, because there I could extend symbol (in)activation to the entire execution stack, which was what I needed. However, the technique you propose is safer, since it is based purely on lexical scoping constructs.
Jan
4
comment Generating assignments and transforming code inside Holding forms when generating code
Your technique is pretty close to the idea I discussed in this answer, although there I didn't go into as much detail as you did here. B.t.w., the answer of WReach for the same question is also relevant in this context.
Jan
4
comment Generating assignments and transforming code inside Holding forms when generating code
+1, it is an interesting technique. But as far as I can tell, you can use any head (perhaps having Hold* or HoldAllComplete attributes) in place of Intactive here - i.e., you don't really use any Inatctive - specific built-in operations (such as Activate, Inactivate). I achieve similar results with the full version of my code-freezing technique, based on the Block trick - with a difference that in my case, "frozen" symbols are hidden by dummy symbols during evaluation, rather than have another head wrapped around them.
Jan
3
comment Generating assignments and transforming code inside Holding forms when generating code
@ManuelOdendahl Well, thanks, accepting within a few seconds of me posting an answer is impressive, but perhaps you could wait for a bit to at least read it - who knows, may be I got tired and posted a load of junk ...
Jan
3
revised Generating assignments and transforming code inside Holding forms when generating code
deleted 3 characters in body
Jan
3
answered Generating assignments and transforming code inside Holding forms when generating code
Jan
2
awarded  Enlightened
Jan
2
awarded  Nice Answer
Dec
31
awarded  Great Answer
Dec
29
revised Attributes with Pattern test
Added links
Dec
29
comment Attributes with Pattern test
@SimonWoods Good to know, thanks. I wasn't aware that this has been discussed in the docs.
Dec
29
comment Attributes with Pattern test
@Algohi I'd rather say that for patterns of the type p_head /; test[p] or p_head?test, the procedure to match the pattern is that first, the p_head part is tested, and if the pattern doesn't match, the test from Condition or PatternTest is simply not performed. So yes, this is a particular form of short-circuiting, very sensible one IMO. I have discussed it in this answer.
Dec
29
comment Attributes with Pattern test
@Algohi Yes, because _List acts as a prefiltering device. This means that the pattern-matcher stops at that point and does not need to call the test function, because it rejects the pattern at an earlier stage of _List.