PaddiM8 / kalker

Scientific calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
https://kalker.xyz
MIT License
1.59k stars 70 forks source link

Add Iverson Bracket #32

Closed abrudz closed 3 years ago

abrudz commented 3 years ago

An Iverson Bracket is simply a predicate in square brackets which evaluates to 0 if false or 1 if true. It is great for defining functions in multiple pieces, for example f(x)=x[x<0]+x^2[x>0]:

image

PaddiM8 commented 3 years ago

That's pretty cool, I've been looking for a way to express something like this! I'll look into it.

abrudz commented 3 years ago

If you like that, and Unicode symbols, then you might like APL

PaddiM8 commented 3 years ago

If you like that, and Unicode symbols, then you might like APL

APL seems fun! Maybe I'll try it some day.

Also, if I implement Iverson brackets, it might also be useful to be able to do recursion... That could actually be pretty useful

PaddiM8 commented 3 years ago

There, seems to work now! Having comparison operators will be useful for other features as well.

>> x = 1/3
>> [0 < x ≤ 1/3]*π + [x ≠ 1]
4.1415926536