# Mathics 0.5

Version of implementation Mathics of programming language Wolfram MathematicaA version of Mathics.

## Examples:

### Hello, World! - Wolfram Mathematica (438):

Evaluation of this expression results in a string “Hello, World!” itself; since it is not followed by a semicolon, it will be printed as a separate `Out`

, which is not always convenient.

```
"Hello, World!"
```

### Hello, World! - Wolfram Mathematica (439):

`Print`

function outputs its argument(s) to the main output stream. Streams can nest, so for convenience it’s recommended to to use a single stream for all output throughout the program.

```
Print["Hello, World!"];
```

### Factorial - Wolfram Mathematica (440):

This example uses built-in factorial function `!`

.

`Do`

is one of the ways to run a loop — it evaluates its first argument for a sequence of numbers defined by the second argument. In this case it’s all values of `i`

from 0 to 16, inclusive, with step of 1.

```
Do[Print[i, "! = ", i!] , {i, 0, 16, 1}]
```

### Fibonacci numbers - Wolfram Mathematica (442):

`Print`

always outputs a newline after the output, so to prints the numbers in a single line, one has to accumulate them into a string and print it. `<>`

is concatenation operator, it works only on strings, so the result of `Fibonacci`

call must be converted to string explicitly using `ToString`

function.

```
msg = "";
Do[msg = msg <> ToString[Fibonacci[i]] <> ", " , {i, 16} ];
Print[msg, "..."];
```

### Fibonacci numbers - Wolfram Mathematica (482):

This example uses `Riffle`

function which in this case alternates elements of the array containing Fibonacci numbers and the separator string “,”.

```
StringJoin[Riffle[Map[ToString, Table[Fibonacci[i], {i,16}]], ", "]] <> "..."
```

## Comments

]]>blog comments powered by Disqus

]]>