Skip to main content
21 votes

How can a verbal reasoning question be solved with Mathematica?

Riffing off of DanielHuber's answer, and with less user intervention: ...
Michael Seifert's user avatar
21 votes
Accepted

Art on mathematica with filled circles and straight paths: how can I reproduce minimalist suns?

...
kglr's user avatar
  • 396k
18 votes
Accepted

Art on Mathematica: How can I export 4K resolution png images?

There are a couple ways to do this! One is with ImageSize, and one is with RasterSize (probably recommended), and they have ...
thorimur's user avatar
  • 9,010
16 votes

Permanently extending the behaviour of functions (like decorators)

Preamble I've used similar constructs a number of times. This answer assumes that you want to decorate at definition time (which is what happens in python), rather than doing that after the ...
Leonid Shifrin's user avatar
16 votes

How can I implement object oriented programming in Mathematica?

Here's I think my 5th version of this type of thing. I've got another framework for this here whose construction I explained here. The package version of this lives on GitHub, which you can load by: ...
b3m2a1's user avatar
  • 46.9k
15 votes

How can I implement object oriented programming in Mathematica?

[...] but I'm hoping someone can suggest a sleek and novel implementation that is easy to use. The answer to this is to use Object-Oriented Design Patterns in Mathematica as explained and ...
Anton Antonov's user avatar
13 votes
Accepted

How can a verbal reasoning question be solved with Mathematica?

To look for a pattern,we get the character codes: cc= ToCharacterCode["KDXPNGVNQJTLTM"] (* {75, 68, 88, 80, 78, 71, 86, 78, 81, 74, 84, 76, 84, 77} *) ...
Daniel Huber's user avatar
11 votes
Accepted

Permanently extending the behaviour of functions (like decorators)

Based on your requirements I would move the original symbol to a new context. ...
Mr.Wizard's user avatar
  • 272k
8 votes
Accepted

Draw Graph with upper and lower limit

x0 = First[x /. Solve[2 10^5 x == 10]] 1/20000 ...
corey979's user avatar
  • 24k
8 votes
Accepted

Longest and Shortest won't work in ReplaceList?

To me this is an interesting problem, however I think the question is a misguided one. Briefly: Longest and Shortest only change ...
Mr.Wizard's user avatar
  • 272k
7 votes

How and why to use monadic programming in Mathematica?

(This answer is code-less, but it is a type of answer I am interested to see for the question. This answer is also a section of "Monad code generation and extension"; [AA3].) ( It might be a good idea ...
Anton Antonov's user avatar
7 votes

How and why to use monadic programming in Mathematica?

(This answer comprises a few of the sections of the blog post "Monad code generation and extension"; see also [AA11].) The basic Maybe monad It is fairly easy to program the basic monad Maybe ...
Anton Antonov's user avatar
6 votes

What's the analogue of UML in Mathematica land?

This answer shows how to create UML diagrams in Mathematica. It is related to programming in Mathematica using Object-Oriented Design Patterns as discussed in my answer to the question General ...
Anton Antonov's user avatar
6 votes

Permanently extending the behaviour of functions (like decorators)

A seemingly robust approach seems to be to modify the RHS of DownValues of the symbol you want to decorate. So lets define a decorator function: ...
TimRias's user avatar
  • 3,160
5 votes

Art on mathematica with filled circles and straight paths: how can I reproduce minimalist suns?

Something like: ...
Daniel Huber's user avatar
5 votes
Accepted

Equivalent of Nothing for patterns

You could use Repeated[..., {0,1}] to match elements which may appear zero or one times, but there's even better option in this case, that is, ...
kirma's user avatar
  • 19.1k
4 votes

How can I implement object oriented programming in Mathematica?

Minimal Object Implementation As part of extending my other answer, I came up with a minimal mutable object implementation: ...
b3m2a1's user avatar
  • 46.9k
4 votes

How and why to use monadic programming in Mathematica?

I think the monad comprehensions style is easier for many (including me) to read and understand, especially if there is existing familiarity with set theory. I would like to make the case that code ...
fairflow's user avatar
  • 1,028
4 votes
Accepted

How to define the pattern for the sum of some specified terms?

A similar question was asked on this stack exchange page about an equivalent for nothing for patterns. The solution was to use Optional. Using one of the answers ...
userrandrand's user avatar
  • 5,882
4 votes
Accepted

Obtaining Pairs of Consecutive Elements with Conditional Adjustment

...
Syed's user avatar
  • 54.5k
4 votes

Obtaining Pairs of Consecutive Elements with Conditional Adjustment

list = {2, 5, 8, 12, 16, 20, 24, 28, 31}; Using SequenceCases ...
eldo's user avatar
  • 70.8k
3 votes

Permanently extending the behaviour of functions (like decorators)

It seems that argument-less case (g[]) is special and even if you manually reorder DownValues ...
Kuba's user avatar
  • 137k
3 votes

Can one identify the design patterns of Mathematica?

OOP Design Patterns Many of the Object-Oriented Programming (OOP) Design Patterns can be (relatively) easily implemented in Mathematica without using preliminary code (packages). This answer in the ...
Anton Antonov's user avatar
3 votes

How can I implement object oriented programming in Mathematica?

Data abstraction is one aspect of object-oriented programming, in my opinion, the most important aspect. I frequently use a schema abstracted, I hope in a very obvious way, from the following example, ...
Reb.Cabin's user avatar
  • 8,661
3 votes

Longest and Shortest won't work in ReplaceList?

As a workaround, you can use Select to filter down the results of ReplaceList to the set you want by using ...
Edmund's user avatar
  • 42.3k
3 votes

Unusual performance of the Cases function

The explanation stems from the Attributes of Condition (short form /;), which contain ...
Michael E2's user avatar
  • 236k
3 votes

Unusual performance of the Cases function

Consider: SeedRandom[1]; Cases[{{1, a}, {2, b}, {3, c}, {4, e}}, X_ /; X[[1]] == Part[RandomSample[{1, 3}, 1], 1]] // Trace As you can see, RandomSample is ...
Daniel Huber's user avatar
3 votes

Is there a way to make $g$ changeable independently of $f$ in this code?

Whenever I see an equation with an integral, I always think about trying to convert it into an ODE. Your question falls into this category. So, let's differentiate your equation: ...
Carl Woll's user avatar
  • 131k
3 votes

Equivalent of Nothing for patterns

The comment section got a bit long and as it would be tedious for someone else to read through the comments I moved my last comment, that only solves this specific situation, to an answer. I had never ...
userrandrand's user avatar
  • 5,882
3 votes

How to define the pattern for the sum of some specified terms?

This feels a bit jenky, but maybe it'll work. I'm making a couple of assumptions, so you'll probably need to refine. Here is a list of cases that attempt to match individual terms: ...
lericr's user avatar
  • 28.3k

Only top scored, non community-wiki answers of a minimum length are eligible