[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shell wrappers for trig and other mathematical functions



On Tue, Oct 01, 2019 at 09:18:13PM -0700, Dan Hitt wrote:
> It does look like a way to quickly get values for sine (or any other
> function in perl).
> 
> However, i would like to dispense entirely with the 'perl -e' and 'print'
> part.

You can't.

> I really would like stand-alone programs.

Gods, no!  You do not.  Why on earth would you think you want a dedicated,
stande-alone program for this?!

> This would absolutely
> minimize any typing,

Oh, you just want to MINIMIZE TYPING.  Then write a series of shell
functions.

wooledg:~$ sin() { perl -e 'print sin $ARGV[0], "\n"' "$1"; }
wooledg:~$ sin 1
0.841470984807897

This is what shell functions are for.  You can just drop the shell
functions into your ~/.bashrc and then use them in every interactive
shell thenceforth.

I strongly recommend this approach over the aliases that were previously
suggested, by the way.  Functions are so much cleaner.


Reply to: