Skip to main content
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 ...
Anton Antonov's user avatar
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. ...
Simon Woods's user avatar
  • 85.2k
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 ...
brenton's user avatar
  • 521
39 votes
Accepted

3D tree in Mathematica?

First, an idomatic, but slow version. ...
Henrik Schumacher's user avatar
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 ...
C. E.'s user avatar
  • 71k
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 ...
Sascha's user avatar
  • 8,519
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: ...
Roman's user avatar
  • 49.3k
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} ...
kglr's user avatar
  • 399k
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: ...
Szabolcs's user avatar
  • 236k
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 ...
Anton Antonov's user avatar
29 votes

Code that generates a mandala

Completeley trial & error, but you can play around with it to your heart's content: ...
martin's user avatar
  • 8,830
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: ...
Henrik Schumacher's user avatar
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, ...
Cory Walker's user avatar
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, ...
rcollyer's user avatar
  • 34.1k
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] ...
Greg Hurst's user avatar
  • 36.4k
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 ...
Mr.Wizard's user avatar
  • 273k
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 ...
halirutan's user avatar
  • 113k
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. <...
Mr.Wizard's user avatar
  • 273k
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 ...
Thies Heidecke's user avatar
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 ...
Anton Antonov's user avatar
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 ...
faysou's user avatar
  • 11k
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 ...
Picaud Vincent's user avatar
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 ...
gwr's user avatar
  • 13.6k
21 votes
Accepted

Programming a bishop's move on a grid

...
kglr's user avatar
  • 399k
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 ...
Batracos's user avatar
  • 2,115
20 votes

Is there a more elegant way to write this statement?

Total[Range[CubeRoot[10000]]^3] 53361
Niki Estner's user avatar
  • 36.2k
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 ...
Anton Antonov's user avatar
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 ...
Jason B.'s user avatar
  • 69.7k
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 ...
Anton Antonov's user avatar
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, ...
Anton Antonov's user avatar

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