Update June 2015 Here is an updated version of the program. I've made it compatible with newer Mathematica versions (AstronomicalData returns Quantity structures in newer versions, which wrangled ...

I found a curious style of debugging that I call "Epicsauce Debugging Level 2." First you type this: x = 0; While[True, Pause; (*Dynamic[x]*) x++ ]; Then you highlight the Dynamic[x] and ...

Well I guess one more couldn't hurt. Using an iterated matrix-replacement scheme and some fancy opacity: powzerz = 2; width = 550; primitive = Scale[Cuboid[], 0.99999]; matrix0 = {{{1}}}; matrixT = ...

My take: toward[p1_, p2_, v_: .05] := p1 + v Normalize[p2 - p1]; {n, r} = {4, 3}; DynamicModule[{pts, history}, pts = r {Cos[#], Sin[#]} & /@ Range[2 Pi/n, 2 Pi, 2 Pi/n]; history = {pts}; ...

Well, the smartass answer would be ContinuedFraction[E - 2, n] So your approximation function (if I understood correctly) would be FromContinuedFraction[ContinuedFraction[E - 2, n]] But the way I ...

The Hold functions enable Mathematica's version of what some other languages call "macros." You can use them for a lot of things, but the essential point is that they preserve the structure of the ...

In some languages Print behaves like the identity function. But as noted, Print in Mathematica returns Null. I want to make clear what is going on with the memoization idiom, for those who might be ...

I made a program of this kind before and the most efficient solution I found was Cuboid. Or perhaps it was the best-looking solution. The rendering code is: render[stack_, iterations_, color_, ...

It looks like you can use VertexShapeFunction to do it (also take a look at the other options for Graph). Modifying one of the examples from the documentation: Graph[{1 -> 2, 2 -> "bob", "bob" -...

Something along the lines of Rotate[Line[pts], angle, Mean[pts]]: g = Graphics[Line[{{1, 1}, {2, 2}}]]; rot = l : Line[pts_] :> Rotate[l, Pi/2, Mean[pts]]; Show[g, g /. rot] I believe that ...

Have you looked at SectorChart? Here's one approach using RegionPlot. Note that because of the range of values ArcTan returns, you should specify angles between -Pi and Pi: SegmentPlot[segmentList_, ...

Here's a relatively straightforward "first version": ellipsizeMax = 8; ellipsize[str_] := If[StringLength[str] > ellipsizeMax, StringTake[str, ellipsizeMax] <> "\[Ellipsis]", str]; readDir[...

For educational purposes, here's a couple other ways to do this: Power @@@ {{1, 2}, {2, 2}, {3, 2}} Power[Sequence @@ #] & /@ {{1, 2}, {2, 2}, {3, 2}} Cases[{{1, 2}, {2, 2}, {3, 2}}, List[x__] :...

The answer to the more general question of how necessary "software architecturizationing" is in Mathematica is, in short: Not that necessary. The reason is basically 1) lists 2) dynamic typing and 3) ...

Take a look at the output of PolyhedronData[{"Prism", 3}, "Faces"]}, which may help. Note this isn't exactly a direct answer, but I think the optimal solution here is a tool that would let you... ...

This is not necessarily an answer, but the Mathematica system is very flexible and I think you might be able to accomplish what you're after with Mathematica itself. Look at this code here: nbWindow =...

stringToHex[str_] := ToExpression["16^^" <> str]; This is just a way of automating the normal notation you would use, which is 16^^6b (check here for the documentation).

Here's a plain pattern approach, I'm not quite sure how robust it is: ReplaceList[expr, {___, "Open", x : Except["Close"] ..., "Close", ___} :> {x}] Also take a look at Longest and Shortest, ...

Not a direct answer to your question, but I've found RandomChoice is generally the most "intentful" of the random functions. With RandomChoice, your code would be something like: randomWalk[n_, p_: ....

I can't tell what you're doing either, but here's an idea using Nearest: l1 = Table[{x, 1 + x^2}, {x, -2, 2, .005}]; l2 = Table[{x, 1/2 x^2}, {x, -2, 2, .005}]; d = {#[], EuclideanDistance[#, ...

Here's a "compositional" approach. If you take things piece-by-piece it is not too hard to build up more complicalated demonstrations. Animate[Module[ {spazzyP, scrollingPaper, scrollingSine, ...

I think this particular scenario has to do with how you can create your own Import/Export filters: Developing an Import Converter Regarding 'verification' as in the Plot[Sin[x], {x, -Pi, Pi}, Frame -&...

A solution using the built-in Cycles comparison: numbering = MapIndexed[#1 -> #2[] &, Sort[set[]]]; DeleteDuplicates[set, Cycles[{#1}] == Cycles[{#2}] /. numbering &]

Here's an approach that uses a more explicit rule replacement: MapIndexed[{##} /. {coeff_ sym_ | sym_, {index_}} :> index^2 sym &, expr]

I think you've actually done a good job considering you are only using Manipulate. Here's a simplified snake game using Dynamic: snake = {{0, 0}, {0, 1}, {0, 2}}; dir = {0, -1}; directions = { "...

From the documentation for Print: "Print sends its output to the channel $Output." Therefore you can just do this:$Output = OpenWrite["filename " <> DateList["Year", "Month", "Day"] <> "...

My friend, what you ask for is madness. Assuming you're completely aware of just doing this, or similar: Show[ PolarPlot[{4/Cos[theta], 4/Sin[theta]}, {theta, -6, 6}], Graphics[Rotate[Line[500 {{-1,...

Combine the background and the Graphics with Show, so that you can supply both of them as the second argument to LocatorPane: background = Image[Graphics[{LightGray, Rectangle[]}]]; DynamicModule[{...