Jump to content

Eban numbers: Difference between revisions

m
Line 1,082:
'$it;' -> (<'([246]|[3456][0246])(0[03456][0246])*$$'> $it !) -> $number !
end isEban
</lang>
 
Alternatively, if regex is not your thing, we can do it numerically, which actually runs faster
<lang tailspin>
templates isEban
def number: $it;
$it -> (<1..> $it!) -> #
<0> $number !
<?($it mod 1000 <0|2|4|6|30..66?($it mod 10 <0|2|4|6>)>)> $it / 1000 -> #
end isEban
</lang>
 
Either version is called by the following code
<lang tailspin>
def small: [1..1000 -> isEban];
$small -> !OUT::write
Line 1,112 ⟶ 1,125:
 
' -> !OUT::write
</lang>
 
Alternatively, if regex is not your thing, we can do it numerically, which actually runs faster
<lang tailspin>
templates isEban
def number: $it;
$it -> (<1..> $it!) -> #
<0> $number !
<?($it mod 1000 <0|2|4|6|30..66?($it mod 10 <0|2|4|6>)>)> $it / 1000 -> #
end isEban
// Same calling code as above
</lang>
{{out}}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.