tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Mathematical functions #61

Closed egorsmkv closed 8 years ago

egorsmkv commented 9 years ago

Hi, @tdenniston

I have created just such a library: https://gist.github.com/eg0r/4da3b0d75cabcbe29e1f

PR did not do, as it is necessary to formalize the library. I propose to move it to a separate folder and there are going to bish-files to be imported one, for example, stdlib.bish.

Yeah, well, I ask to comment on my code, it can be somehow need to improve?

tdenniston commented 9 years ago

@eg0r Thanks, this is great!

Your code looks good. I will create a separate folder for libraries and move stdlib.bish there. After that, you can create a PR with this library.

One question: is bc available on all systems? Do you know of any systems without bc?

egorsmkv commented 9 years ago

@tdenniston As suggested by Wikipedia must be in UNIX. But it is possible to check in functions that will display abort.

egorsmkv commented 9 years ago

@tdenniston By the way, floating point numbers, you can do so.

def float(x) {
  cmd = "scale=3; $x/1.0";
  return @(echo $cmd | bc);
}

println(float("43")); # => 43.000
tdenniston commented 9 years ago

@eg0r You can submit a PR for this library now.

sandeep06011991 commented 8 years ago

Sorry to intrude , I am a programmer without university education trying to teach myself compilers by working on open source projects . I would really appreciate if you could give me simple tasks , some guidance ,anything at all . All help appreciated

egorsmkv commented 8 years ago

@sandeep06011991 Notes? Clone project and experiment!