Base-16 representation: Difference between revisions
m
→{{header|Raku}}: More generic display code
m (→{{header|Phix}}: decimal -> "decimal-looking") |
Thundergnat (talk | contribs) m (→{{header|Raku}}: More generic display code) |
||
Line 1,619:
Bah. Show which when written in base 16, contain a digit glyph with a value greater than 9:
<lang perl6>put
sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n" ) {
cache $list;
}</lang>
{{out}}
<pre>301
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
Line 1,643 ⟶ 1,647:
<lang perl6>use Base::Any;
put display :20cols,
▲ .batch(20)».fmt('%3d').join("\n")
▲ given (^501).grep( { .&to-base(-16).contains: /<[A..F]>/ } );</lang>
sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n" ) {
cache $list;
$title ~ $list.batch($cols)».fmt($fmt).join: "\n"
}</lang>
{{out}}
<pre>306 matching:
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|