@JM The question went wild here and it was the topmost question on the SE hot list all day... Having a title like "30 days of beta..." screams meta to everyone who doesn't take the time to read the question, so at a quick glance Robert saw that it was basically a fun question with a block of code that said "Here, improve this!", and so he moved it to meta. Can't say I entirely disagree with his assessment there...
After convincing him that there was a question buried and will be dug out improved, he agreed to undo the migration and leave it in a closed state for the community to reopen if it wishes
Anyway, if anyone comes across this, I have something I can't seem to find in the help file. Is there a syntax for Style[] to be able to do something like "this text is in bold, and this text is italicized."?
@JM Let me put it this way regarding StyleBox: take a string, use the Format menu to get what you want, then use Ctrl+Shift+E to see the Box form. I think that's as close as you're going to get.
I am trying to think of a solution to [this problem]. I am facing a lack of understanding of the capabilities available in KeyEventTranslations.tr and MenuSetup.tr. Do you have much experience with this?
Since I cannot find an existing Token to do this, I would have to use a more elaborate function in one of those files. There are examples of both FrontEndExecute and (in MenuSetup) KernelExecute usage in the files. It seems hard to do simple things within FrontEndExecute because there is no FrontEnd`Part for example.
I was trying to use Notebooks[] and SetSelectedNotebook to accomplish this, but even from the Notebook interface I find the need for storage variables. I also tried SetSelection[SelectedNotebook[], Next, Notebook] but that changes what is selected (everything) within the Notebook. Can you think of any other way to approach this?
@Heike Except for hsv() (because we already have Hue[]), gray (GrayLevel[]), white (well...), colorcube, flag, lines, and prism, I've already done the lot... ;)
...though I'm tending to favor jet, bone, and hot for my uses...
The main difference is that there is a gap between the red and blue curve near x==.5 in the "VisibleSpectrum" map which is why it's greener in the middle.
According to the matlab documentation they expect you to use their colormapeditor to edit colour maps. Unless there is a programmatic way that's going to take a lot of time.
Well, the default setup in the M-files for the color schemes is to just generate a 64-by-three matrix, and then interpolate accordingly to expand for finer graduations. (At least, that's how I understood the code.) The color schemes I was able to port, except for pink, were all piecewise linear, so translation was a snap.
(though I had to ask yoda for help with jet because the code in the M-file was rather confusing to parse)
@Szabolcs it seems a bit complicated; I was just wondering about its application, and perhaps if every step you took is necessary. If you feel like giving a slightly longer description of its purpose I may be able to refine it (or not).
brb
Let me float a simple example without all the complication, then you can tell me why it breaks your application:
@MrWizard I was using it to generate code and compile the generated code. Here's an example function. It was going to be part of a solution for one of yesterday's questions, but it is incorrect.
call it with setsC[{{1,2,3,4},{3,4,5,6},{4,5,6,7}}]
@MrWizard The CompilationTarget should read target, but it's irrelevant anyway
@MrWizard I wanted to package it up into a function for ease of use. I wanted to have a simple to understand and simple to use function, and I didn't want to think about its internals at all while using it.
@MrWizard The usual way to inject expressions into other expressions is With: With[{a:=1+1, Hold[{a,a}]]. What's wrong with this here? Well, it conflicts sometimes with the localization mechanism of Compile and Function:
Next try: use your solution to my question to write a similar function. The property of this function that it applies replacements one by one (and therefore the result of one is visible to the other, as in inject[{a -> b, b -> 1}, a]) is an advantage sometimes. People have been asking for a With where previous constants can be used in subsequent ones many time. In some other occasions it's a disadvantage, but I think for this kind of use it would turn out to be useful
(even though I didn't reply on it when I used the function)
@MrWizard Done. I'd love to see a simplification. Some things were bolted onto inject after a previous version was written (notably the Hold mechanism). There's probably room for simplification.
When you pinged me first I was in the middle of a Skype call and chatting with Skype support at the same time. Skype gets more annoying and broken with each version ...
Okay, thanks for the explanation. Let me start with a point about syntax. I think setting HoldFirst on Rule is clever, but it seems potentially troublesome. If one tries to build rule lists and pass them to the function, the behavior changes. Further, using Rule seems to imply the general pattern matching usually available, whereas here one must use a symbol (or do a replacement beforehand). Perhaps using the inject[{a = 1, b = 2}, . . .] is clearer?
@JM I haven't been on Skype in a while; what are you referring to?
(Off topic: Am I the only one who sometimes seens a -> b as backwards? It looks like "a taking the place of b" to me. I'd pretty much gotten used to it, but my backwards-rule inject method reminded me that backward actually seems right.)
@JM One thing I like about Skype is that it seems to have the best underlying technology for video and voice calling. The interface to access it is a different thing though ... but the video calling technology is just amazing. Especially when the connection is not great. I sometimes use MSN and sometimes QQ messenger, and both of those behave much worse than Skype.
@MrWizard That's a good point about changing the behaviour of rules. It can break thing. Why I used rules and not =: it's just because I started from withRules which I was originally using with lists of rules that I passed to it (see this too). Why the HoldFirst in withRules? See my discussion with Leonid on that toolbag post.
@MrWizard but while these made sense for withRules, they don't any more for inject. I agree with you.
@MrWizard somewhat arbitrarily, I started with withRules when writing this function. There's no logical reason why it ended up like this. I agree with everything you said. HoldFirst on Rule can cause trouble, and = instead of -> is more clear. Though maybe not more concise or more clear to implement.
withRules was made because I wanted to re-use parameter lists I had ({a->1, b->2}-like stuff). This function has a different purpose.
Okay, I found the discussion, I'll come back to it later. It appears to bear directly on my next question which is what parts of all of this are to be implicitly held unevaluated?
@MrWizard all of expr must stay unevaluated so I can use it with Compile. I originally didn't use HoldComplete and ReleaseHold, but tried to rely on attributes. This won't work. To see why, consider SetAttributes[f, HoldAll];, then f@f@f@f[1+1] or Nest[f, Unevaluated[1+1], 5]. The former will get evaluated from the outside (the outermost f first), the latter from the inside (the innermost f first). This might change the results (depending on the definition of f).
Neither of the two evaluation orders would work for this case
What I needed was something like f[expr_] := Replace[Unevaluated[expr], x->y], which would do the replacement without evaluating expr, then return the result without evaluating it again.
neither f@f@f[expr], nor Nest[f, Unevaluated[expr], n] achieves this
about that inject, I have been wondering whether all this is really any less clumsy and ugly than just using strings and then evaluating. I have a much harder time reading all this Hold stuff than just string replacements (since with Hold I have to mentally evaluate things to work out what will happen)
@acl I suppose it depends on the source of the object into which you are injecting. If it is your own code then StringReplace is probably fine, but more generally Leonid has shown that ToExpression[ToString[...]] is not reliable.
Internal`InheritedBlock
I have learned recently the existence of such useful function as Internal`InheritedBlock, from this message of Daniel Lichtblau in the official newsgroup.
As I understand, Internal`InheritedBlock allows to pass a copy of an outbound function inside the Block scope:
In[...
That answer has a brief explanation on Internal`InheritedBlock
The best way to do it is Jeopardy style — ask a question that sets the stage for the neat trick and then answer it yourself. For example, see this question (and answer) by WReach just a few minutes ago
Using Mathematica 8, I can check the version of the .NET framework used by NETLink as follows:
Needs["NETLink`"]
InstallNet[];
LoadNETType["System.Environment"];
System`Environment`Version@ToString[]
"2.0.50727.5448"
As you can see, it is the old 2.0 framework. However, my machine has ve...
If you want to spice it up and increase the fun, you could just post the question and wait for a day while the rest of us break our collective minds trying to figure out a neat way, and then post your solution when we fail
@Ted I learned about most undocumented functions like that here and on StackOverflow. After a while it becomes unavoidable. You'll see many more if you browse the site. We have a culture of system spelunking :-)
Is it possible to save a function which was created via Interpolation of some data in such a way that I can use this function in a new mathematica session without repeated interpolation of the data?
For example, I have some data which I interpolate in the following way:
exampleData={{1,1},{2,3}...
Is there a way in which when you choose to format the size of the font within your notebook, for a particular cell, when you go into another cell, the default size font (12pt) will not be re-activated. I want the font size to stay constant throughout the entire notebook, until I go back and need ...
I posted a basic answer with links to the docs. I don't feel up to explaining in detail how to set up, use and modify stylesheets; if someone else does, please do so and I'll remove my answer
in vol 1 (mechanics), the first section (2.5 pages, I think) introduces the concept of the action and calculous of variations. most of the rest of the 10 vol series use this heavily, but that's it for an explanation.