Self-describing numbers: Difference between revisions
Content added Content deleted
(→{{header|AppleScript}}: Added a draft 'selfDescribes' predicate in Applescript) |
(→{{header|AppleScript}}: Updated predicate.) |
||
Line 128: | Line 128: | ||
on selfDescribes(x) |
on selfDescribes(x) |
||
set s to str(x) |
set s to str(x) |
||
set descripn to |λ|(my groupBy(my eq, my sort(characters of s))) of my described({¬ |
set descripn to my str(|λ|(my groupBy(my eq, my sort(characters of s))) of my described({¬ |
||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}) |
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"})) |
||
1 = (offset of |
1 = (offset of descripn in s) and ¬ |
||
0 = ((items ((length of descripn) + 1) thru -1 of s) as string as integer) |
|||
end selfDescribes |
end selfDescribes |
||
Line 168: | Line 169: | ||
-------------------- GENERIC FUNCTIONS -------------------- |
-------------------- GENERIC FUNCTIONS -------------------- |
||
-- True if every value in the list is true. |
|||
-- and :: [Bool] -> Bool |
|||
on |and|(xs) |
|||
repeat with x in xs |
|||
if not (contents of x) then return false |
|||
end repeat |
|||
return true |
|||
end |and| |
|||
-- eq (==) :: Eq a => a -> a -> Bool |
-- eq (==) :: Eq a => a -> a -> Bool |