Category talk:Wren-long: Difference between revisions

m
→‎Source code: Now uses Wren S/H lexer.
(→‎Source code: Added support for ranges of Longs and ULongs.)
m (→‎Source code: Now uses Wren S/H lexer.)
 
(2 intermediate revisions by the same user not shown)
Line 49:
===Source code===
 
<syntaxhighlight lang="ecmascriptwren">/* Module "long.wren" */
 
import "./trait" for Comparable
Line 949:
..(n) { ULongs.range(this, n, 1, true) } // inclusive of 'n'
...(n) { ULongs.range(this, n, 1, false) } // exclusive of 'n'
 
// Return a list of the current instance's base 10 digits
digits { toString.map { |d| Num.fromString(d) }.toList }
 
// Returns the sum of the current instance's base 10 digits.
digitSum {
var sum = 0
for (d in toString.bytes) sum = sum + d - 48
return sum
}
 
/* Prime factorization methods. */
Line 1,244 ⟶ 1,254:
static range(from, to, step) { range(from, to, step, true, from <= to) }
static range(from, to) { range(from, to, 1, true, from <= to) }
 
// Self-explanatory read only properties.
from { _rng.from }
to { _rng.to }
step { _step }
min { from.min(to) }
max { from.max(to) }
isInclusive { _rng.isInclusive }
isAscending { from <= to }
 
// Iterator protocol methods.
Line 1,675 ⟶ 1,694:
static range(from, to, step) { range(from, to, step, true, from <= to) }
static range(from, to) { range(from, to, 1, true, from <= to) }
 
// Self-explanatory read only properties.
from { _rng.from }
to { _rng.to }
step { _step }
min { from.min(to) }
max { from.max(to) }
isInclusive { _rng.isInclusive }
isAscending { from <= to }
 
// Iterator protocol methods.
9,485

edits