Jump to content

Munchausen numbers: Difference between revisions

m
(→‎{{header|AppleScript}}: Added subheadings after restoring inadvertent deletion of another variant.)
Line 252:
=={{header|AppleScript}}==
===Functional===
<lang AppleScript>-- MUNCHAUSEN NUMBER ? ----------------------------------- MUNCHAUSEN NUMBER ? --------------------
 
-- isMunchausen :: Int -> Bool
Line 266:
(class of n is integer) and ¬
n = foldl(digitPowerSum, 0, characters of (n as string)) = n
end isMunchausen
 
 
-- TEST ------------------------------------------- TEST ---------------------------
on run
Line 281:
 
 
-- GENERIC FUNCTIONS ------------------------------------ GENERIC FUNCTIONS ---------------------
 
-- enumFromTo :: Int -> Int -> [Int]
on enumFromTo(m, n)
if m > n then
set dlst to -1{}
repeat with i from m to n by d
set end of lst to i
end repeat
return lst
else
set d to 1{}
end if
set lst to {}
repeat with i from m to n by d
set end of lst to i
end repeat
return lst
end enumFromTo
 
-- filter :: (a -> Bool) -> [a] -> [a]
on filter(fp, xs)
tell mReturn(fp)
set lst to {}
set lng to length of xs
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.