# Give us your best (Mathematica) one-liner

22nd of January 2014 by liz

Here’s another guest post from Allison Taylor at Wolfram, which is part of a series that will help smooth your introduction to Mathematica. Thanks Allison: over to you!

At our 2010 and 2011 Wolfram Technology Conferences, attendees were challenged to come up with their best one-liners—pieces of code written in less than one line, or under 140 characters. The outputs were then judged by their complexity, usefulness, and general cool-factor. The submissions turned out to be quite diverse, thought provoking, and most of all, pretty nifty illustrations of the efficiency of the Wolfram Language.

So it only seemed fitting to tailor some of these small bundles of powerful code to the equally small-but-mighty Raspberry Pi. (To run these, you must first open the front-end version of Mathematica on your Pi by clicking the Mathematica icon.)

Echidnahedron (AKA, the Mathematica Spikey), by Radko Kriz

We couldn’t help but start off with teaching you how to make a cool, geometric logo similar to the one that has been representing Mathematica and Wolfram Research for over 25 years! The echidnahedron is a “stellation” of the icosahedron—basically, it takes the faces of the icosahedron and turns them into infinitely extending spikes. Or Spikey, as we like to call it.

` Graphics3D[{Opacity[.8],Glow[RGBColor[1,0,0]],EdgeForm[White],Lighting ->  None,PolyhedronData["Echidnahedron","Faces"]}]`

The Ulam Spiral, by Dave Lawrence

Along a similar mathy theme, the Ulam Spiral is a beautiful way to visualize prime numbers. The spiral is contructed on an integer coordinate plane, starting at (0,0) and spiraling outward through every point that is prime.

```s = {Re@#, Im@#} & /@      Fold[Join[#1, Last@#1 + I^#2 Range@#2/2] &, {0},        Range@140]; ListPlot[s, Joined -> True,    Epilog -> {Point /@ s[[Prime@Range@PrimePi@Length@s]]}]```

Not the biggest bang Stanislaw Ulam ever made, but neat nonetheless

Test If an Integer Is a Prime Number, by Sascha Kratky

And while we’re on the subject of prime numbers, there are tons of math and computation examples where this little gem of code will likely come in handy. Run this function with any integer, and it will return True if it is prime and False if it is not.
```RegExPrimeQ[n_Integer] := !      StringMatchQ[StringJoin[Table["1", {Abs[n]}]],        RegularExpression["^1?\$|^(11+?)\\1+\$"]] RegExPrimeQ[17]```

Make Your Own Borg Cube, by Alex Hirsbrunner

You know you’ve always wanted to make one. By tiling a bunch of randomly generated cubes of random sizes and colors, this code will create your very own one-of-a-kind Borg cube to assimilate all your friends into the hive mind.
```p := Random[]; r = RotateLeft; Graphics3D[    Table[{RGBColor[.2, p, .2],      Cuboid[l =          r[{z, p, p}, a], l +          r[p/              8 {Sign[z - .5], p, p}, a]]}, \ {z, {0, 1}}, {a, 0, 2}, {6!}]]```

Fractals, by Stephan Leibbrandt

Make a “heart-shaped box of wires and springs” with this nifty line of code!
```Image@Compile[{},        Block[{i, x, p},          Table[i = 0; x = 0. I; p = r + I c;            While[Abs@x      Tanh[Power[i/9^3, (7)^-1]], {c, -1, 1, .01}, {r, -2, 1,.01}]]][]```

Rubber Duck, by Paul Abbott

And we’ll leave you with this cute little creation, made using a series of spherical functions, because it’s just adorable, isn’t it?
```SphericalPlot3D[    Log[\[Theta]] + Sin[\[CurlyPhi]], {\[Theta], 0,      2 \[Pi]}, {\[CurlyPhi], 0, 2 \[Pi]}, Boxed -> False, Axes -> False,    PlotStyle -> Yellow, Mesh -> None, PlotPoints -> 30]```

Inspired? Show us what Raspberry Pi oriented one-liners you can come up with!

###### In the forums
• FLYFISH TECHNOLOGIES, just now: Other projects • Re: Hi, looking for a project?
Hi,gamemaker123825 wrote:can someone give me links or websites or books to read,Start here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=41&t=51436Search feature of this forum is also handy... and uncle Google can also be your best friend.Best wishes, Ivan Zilic.
• redhawk, just now: Other projects • Re: Hi, looking for a project?
Perhaps - http://www.amazon.co.uk/Adventures-Rasp ... i+projects ?? - I can't comment on the book personally but it has fairly favourable ratings.What exactly do you want from your Pi i.e. write programs in a certain language or attach stuff to the GPIO…
• FLYFISH TECHNOLOGIES, just now: Networking and servers • Re: Help with sub domains
Hi,telakenesys wrote:I have a single static WAN IP. What do I need to do this? I want both sub domains on the same Pi.You need to update records for the domain on your DNS server - one line is needed…
• telakenesys, just now: Networking and servers • Re: Help with sub domains
What I would like to ultimately do, is have a postfix, dovecot, roundcube mail solution and then a multi user blog or simple CMS.I would also like, if I can, to have my blog users automatically setup for an email…
• gamemaker123825, just now: Other projects • Hi, looking for a project?
Hi I just got two new raspberry pi's today and can someone give me links or websites or books to read, I want to do something with them but I'm not sure what, can you guys give me some ideas,…