One way to merge all these mini-modules with translations into one file:
# include-file ``math_notation.nim``
when declared math.PI:
const π = PI
const τ = TAU
# and so on
when declared someAnotherModuleToTranslate.someExportedSymbolFromIt:
templat
I said it's not hopeless. On windows some symbols are even easier to type, just
1-4 numbers on number pad, while holding Alt — say this em-dash; you won't
remember all codes, but 20-40 is realistic.
But it doesn't help you to use `proc √*(p, n: float): float`, as in the
example, even just proc
Typing these unicode symbols from the keyboard is not a big problem
>From the [wikipedia](https://en.wikipedia.org/wiki/Unicode_input): "For
>example, GTK+ is an ISO/IEC 14755-conformant system[citation needed]. The
>beginning sequence is Ctrl+⇧ Shift+U and the ending sequence is ↵ Enter or
>Sp
It's a matter of code readability and beauty :-) For example, modern code
editors may replace the keyword "sqrt" with the symbol " **√** " when checking
the syntax, but it would always be optional.
Hi, @mrhidas.
Yes, some mathematics-related code could be prettier. Of coarse the harder part
is to get into the way of typing them. But not hopeless I think. :)
But not to overestimate what can be done:
import math
proc √*(n: float): float = sqrt(n)
assert (√ 25) == 5
Thank you @LeuGim for your effort in dealing with infinity... even if not
really.
I remembered another symbol with infinite decimal places (π), but there are
many more.
import math
# const π = 3.141592653589793...
const π = PI
echo π
Run
These symbo
@cblake \- thank you for commenting! I didn't like that exactness for `inf(0)`
too, but wanted to respond with that before this thread gets into oblivion. I
put there a new version, which is
[YetMoreFun](https://github.com/Leu-Gim/Nim-modules/blob/master/yetmorefun.nim)
and more in line with yo
@LeuGim \- nicely done & interesting approach!
I'm not sure I would have embued `inf(0)|Infinite(0)` with as precise semantics
in your `for 3 .. inf(0): ...` construction. Infinity is more a process than a
number. For `∞ - ∞ ~ inf(0)` to act like zero the two limiting processes have
to precisel
For something "more infinite" try
[JustForFun](https://github.com/Leu-Gim/Nim-modules/blob/master/justforfun.nim).
Your examples should work with that as expected, and even in an infinite
amount of time. BiggestInt seems not so much fun - will print just some looong
finite number.
Thanks @leorize it's so easy! and work :-)
const ∞ = high(BiggestInt)
echo ∞
for number in -∞ .. ∞:
echo number
Run
Have fun
const ∞ = high(BiggestInt)
echo ∞
Run
I assume you realize that your second example will not get to "Year Zero" since
it sure looks like you are requesting an infinite number of B.C. years?
Not sure you want to build an entire lazy evaluation system and symbology like
Perl6..It's easy to do an infinite iterator by just doing your ow
The Perl 6 language has a symbol to represent infinity (∞). Anyone have any
ideas on how I can implement it in nim? Just for fun!
Use cases:
import math
import strformat
proc is_prime(n: int64): bool =
for i in 2 .. n-1:
if (n mod i) == 0:
13 matches
Mail list logo