News for hackers. Stuff that matters.
Re:Integrated command line math by ubasu on Tuesday July 23, 2013 @02:23PM (#6091912)
Or:

  echo "$1" | bc -l
No need to rev up python.
Re:Integrated command line math by eieio on Tuesday July 23, 2013 @03:20PM (#6092299)
I thought the same thing until I got to the part where the author used

  from math import *
Which gives you significantly more options.

I love this idea, I have always found math in the command line to be clunky.

Re:Integrated command line math by ubasu on Tuesday July 23, 2013 @03:41PM (#6092421)
That is true, but I have found if I am doing calculations that need something like the full math library of python, it's not a one-off calculation, and I am typically on octave anyway.

In any case, since I have emacs open all time, I usually do

  M-x calc
for one-off calculations.
Re:Integrated command line math by merlincorey on Tuesday July 23, 2013 @04:42PM (#6092757)
I just evaluate random lisp in my buffers, sometimes evaluating it to output directly there. Ah emacs!
Re:Integrated command line math by omaranto on Tuesday July 23, 2013 @07:25PM (#6093561)
I do that too, with textadept & Lua instead of Emacs & elisp.
Re:Integrated command line math by gnosis on Tuesday July 23, 2013 @02:38PM (#6092025)
A little syntactic sugar (in zsh):

  function calc {
    print $1 | bc -l
  }
Then:

  calc "(1+2)*3"
  9
zsh actually comes with its own little calculator:

  zcalc "(1+2)*3"
  1> 9
  2> 
Among other things, it features "full command line editing, including the history of previous calculations".
Re:Integrated command line math by _ZeD_ on Tuesday July 23, 2013 @03:33PM (#6092385)
minor nitpick, you don't need "echo"

    $ bc -l <<< 3+2
    5
    $