what is the nim equivalent to the python None type

2024-03-14 Thread isaiah
okay. thanks i will look into that

what is the nim equivalent to the python None type

2024-03-14 Thread enthus1ast
Your code does not compile. Also, i see no reason to actually have a "isNone" check. Nim is not Python, so the parameters for `initPoint` and `+` CANNOT be nil. So no need to actually try to check.

what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newException(ValueError, fmt"({x}, {y}) is not on the curve")` Run

what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`import std/[strformat, options] import math type TypeError = object of ValueError type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newExcept

what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newException(ValueError, fmt"({x}, {y}) is not on the curve") ` Run

what is the nim equivalent to the python None type

2024-03-08 Thread Araq
> In most cases, you should use Option if you need something that could be > none, and avoid nil, even on reference types. I beg to differ. It allows for the state `Some(nil)` which you cannot easily prevent at compile time.

what is the nim equivalent to the python None type

2024-03-07 Thread isaiah
thanks a lot for the explanation.I am actually trying to translate the jimmy song programming bitcoin book from python to nim in order to actually learn nim. I am trying to implement the Point field with infinity.

what is the nim equivalent to the python None type

2024-03-07 Thread termer
What are you wanting to represent with it? If you're just trying to represent whether something is present or not, the `Option` type will do well. It's also typesafe, and won't crash the program if you try to use it as a normal value. On the other hand, you can use `nil` for ref types, which is

what is the nim equivalent to the python None type

2024-03-07 Thread Isofruit
Strictly speaking python's "None" is basically equivalent to "null" in Java is equivalent to "undefined"/"null" in JS. That one is equivalent to nim's "nil". That type you will **only** get if you deal with ref-types, aka when you declare your type like so: type A = ref object

what is the nim equivalent to the python None type

2024-03-07 Thread isaiah
it seems it will solve the problem.thanks alot.

what is the nim equivalent to the python None type

2024-03-07 Thread juancarlospaco
Kinda but not really.

what is the nim equivalent to the python None type

2024-03-07 Thread isaiah
I am translating a python code to nim and i need to find out the nim equivalent of None