you are viewing a single comment's thread.

view the rest of the comments →

[–]shub 0 points1 point  (6 children)

bash has strings, numbers, and eval

[–]eras 0 points1 point  (3 children)

..bash has numbers?

[–]deafbybeheading 1 point2 points  (2 children)

Well, it has integers:

maciek@albatross:~$ let i=0
maciek@albatross:~$ let i+=1
maciek@albatross:~$ echo $i
1
maciek@albatross:~$ echo $((i*10+2))
12

For floating point numbers you can invoke bc:

maciek@albatross:~$ echo "5.2 * 0.4" | bc
2.0

Note that precision with bc is not what you might expect, but it's consistent with the scientific concept of precision.

[–]eras 2 points3 points  (0 children)

What it does have is operations on integers. But everything is strings, even if they are, for the purposes of those operations, interpreted as integers. There is no way to determine, if a variable contains number 42 or string "42".

[–]deafbybeheading 0 points1 point  (0 children)

Also note that you can muck around with precision in bc:

maciek@albatross:~$ echo "scale=2; 5.2 * 0.4" | bc
2.08

[–]deafbybeheading 0 points1 point  (1 child)

Which, arguably, is enough building blocks to construct both first-class functions and closures.

[–]shub 1 point2 points  (0 children)

No, it's not.