105
votes
Code that generates a mandala
Here is one way to come up with "mandalas" -- we generate a segment and then by appropriate number of rotations we produce a "mandala".
Here is an example function of a random seed segment ...
68
votes
Code that generates a mandala
For this one I've defined three types of layer, a flower, a simple circle and a ring of small circles. You could add more for greater variety.
...
46
votes
Is there a linter to help write good Mathematica code?
I am a developer at Wolfram Research and I have been working on linter technology that I think would be nice to share publicly.
There are 2 paclets on the public paclet server that you can download ...
39
votes
Accepted
37
votes
Accepted
The Game of Hex in Mathematica
The flow in my program is:
I have one global variable, board, which is an 11x11 matrix. Each matrix element corresponds to a hexagon on the board.
I pass the board ...
35
votes
Accepted
Generate landscape by cutting a plane in 3d
My solution does not follow the algorithm you described to the word (I don't choose two random points and find the line equation that runs through them but instead choose a random line equation) but ...
34
votes
Creating the Yin Yang symbol with minimal code
Unicode:
\:262F
(* ☯ *)
For post-processing at higher resolution, we can rasterize this character to arbitrary pixel counts:
...
34
votes
Accepted
Creating the Yin Yang symbol with minimal code
d = {#, 0} ~ Disk ~ ##2 &;
Graphics@{d[4, 8, {0, π}], 8~d~4, {White, 0~d~4, d@8}, d@0, Circle @@ 4~d~8}
...
31
votes
Accepted
What are some approaches to measuring code coverage?
Yes, there is a coverage tool, and it's pretty good.
First, you need to install the required packages:
...
30
votes
Code that generates a mandala
The point of using machine learning algorithms for generation of mandala images mentioned in the comments of my previous answer is clarified in this blog post:
"Comparison of dimension reduction ...
29
votes
Code that generates a mandala
Completeley trial & error, but you can play around with it to your heart's content:
...
29
votes
Analogies to Help New Users
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays: ...
28
votes
Is there an open source implementation of Mathematica-the-language?
Expreduce
Expreduce is a new MIT-licensed project that has a fairly complete implementation of the language semantics. Further, it has a nice collection of definitions that provide CAS functionality, ...
26
votes
How to make Mathematica variables declarative instead of just-in-time?
You are looking for $NewSymbol which is run every time a new symbol is created. For example, let say you only want x, ...
26
votes
Accepted
Sisyphus Random Walk
We can iterate with FoldList:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
...
25
votes
Accepted
Programming the fiver game
In this case I don't know how to post something helpful without providing full code so I'll just do that and hope this wasn't homework. My emphasis is on clarity (hopefully) rather than brevity or ...
24
votes
Accepted
How to put Mathematica Notebooks and packages on Github?
General comment
Your question suggests that you might be on the wrong or at least on a stony path. Let me try to clear some things up even if it is not strictly Mathematica correlated.
Yes, you can ...
24
votes
Can we intelligently control evaluation in Thread?
Analysis of the problem
All functions in Mathematica either hold one or more of their arguments, or per The Standard Evaluation Procedure the arguments are evaluated before the function is applied. <...
24
votes
Accepted
Simulation of diffusion in a grid
You can use ListConvolve to simulate a single diffusion time step and build a simulation out of that. I'll show a simple example: Let's say we start with simple ...
24
votes
Accepted
Programming language prototyping in Mathematica
General
Some general answers and comments first.
1
Are you aware of any projects using the Wolfram language resp. Mathematica as an environment to explore the design of programming languages - in ...
23
votes
Once more on object orientation in Mathematica: does it have to be so hard?
After years of development, I'm releasing a package called MTools on github.
The package is under an MIT license. You can fork it and send pull requests.
The main contribution of MTools is to allow ...
23
votes
What are the recommended settings for git when using with Mathematica projects?
The solution I am currently using is to work with *.wls script files.
You can do nearly all the things you do with usual *.nb notebooks files (as shown in my screen shot).
The big advantage is ...
21
votes
Accepted
Where can I get Workbench 3 and why do I need it?
Update November 25, 2022 (There is hope after all...)
I was told by @RolfMertig in a comment that I may have been "too harsh" with Workbench/Eclipse and giving it some consideration, I have ...
21
votes
Accepted
20
votes
How do you set attributes on SubValues?
This is an old discussion but is about an issue that resurfaces every now and then. One of the best (for a given sense of elegance) answers is the one posted on Stack Overflow
...
20
votes
20
votes
The Game of Hex in Mathematica
Here is an answer that provides modular definitions that allow
plotting the play-table and players moves with different options, and
testing for a complete path by a player.
(The function ...
20
votes
Creating the Yin Yang symbol with minimal code
I think the code in the OP is nice and concise, and generates a good graphic. But if brevity is the goal, you can turn to the Knowledgebase via
...
19
votes
Accepted
Functions with changeable global variables
Introduction
The question is: how to correctly organize all this?
Of course, there are many ways to answer the question, ranging from re-education suggestions to click-through paths in a relevant ...
18
votes
Monad-like structures in Mathematica
General
My (biased) view on monads is that they are loudly advertised in Haskell and F#, but I kind of do not see what is the big deal. (Granted, similar things are said about OOP Design Patterns, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
programming × 1596list-manipulation × 215
functions × 111
performance-tuning × 111
function-construction × 98
evaluation × 57
equation-solving × 55
plotting × 48
graphics × 48
matrix × 48
dynamic × 48
syntax × 45
mathematical-optimization × 40
notebooks × 39
functional-style × 37
front-end × 36
scoping × 34
graphs-and-networks × 33
pattern-matching × 33
differential-equations × 32
manipulate × 32
algorithm × 32
recursion × 31
core-language × 31
probability-or-statistics × 29