Binary digits: Difference between revisions
Content added Content deleted
(→{{header|AppleScript}}: Normalised argument sequence of showIntAtBase, updated primitives) |
|||
Line 220:
<lang AppleScript>
intercalate(linefeed, ¬▼
map(binaryString, [5, 50, 9000]))▼
end run▼
on binaryString(n)
showIntAtBase(
end binaryString
Line 236 ⟶ 229:
-- showIntAtBase :: Int -> Int -> String
on showIntAtBase(
if base > 1 then
if n > 0 then
Line 242 ⟶ 235:
set r to n - m
if r > 0 then
set prefix to showIntAtBase(base, r div
else
set prefix to ""
Line 261 ⟶ 254:
end if
end showIntAtBase
-- TEST
on run
▲ intercalate(linefeed, ¬
▲ map(binaryString, [5, 50, 9000]))
▲end run
Line 268 ⟶ 271:
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
repeat with i from 1 to lng
set
▲ end repeat
end map
Line 288 ⟶ 289:
end intercalate
-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
if class of f is script then
f
▲ else
script
property lambda : f
end script
end if
end mReturn</lang>
|