thx.core
thx.core copied to clipboard
Int gets coerced to Time somehow?
I'm still trucking along in learning Haxe by doing /r/dailyprogrammer challenges. One of the minis for the week has me calculate the number of "ramp numbers" less than a given number. This program should solve it:
using Thx;
class RampNums {
static function main () {
var rampNums = 0, arg = Sys.args()[0].ifEmpty("100");
for (i in 1 ... (arg.canParse() ? arg.toInt() : 100))
if (i.toString() == i.toString().toArray().order.fn(
_0.toInt() - _1.toInt()).join("")) rampNums++;
Sys.println(rampNums.toString());
}
}
However, when I run the generated bin through the cpp build, I get a time: 1969-12-31 19:00:00 And when I build with neko and run that, I get a crash...
Called from ? line 1
Called from RampNums.hx line 6
Called from RampNums.hx line 6
Called from thx/Iterators.hx line 147
Called from /usr/lib/haxe/std/neko/_std/Array.hx line 344
Called from a C function
Called from RampNums.hx line 7
Uncaught exception - Invalid operation (-)
Do you have any ideas in regards to this weirdness?
Can you try to reduce that code to a minimal sample? It is really hard to pin point what is going wrong there.
Seems like this is enough to reproduce it: http://try.thx-lib.org/#Cd0F4
If you remove the .toString() in the trace(), it outputs the correct number.
Thanks, it is a precedence issue. Will fix it.