Self-describing numbers: Difference between revisions

→‎{{header|AppleScript}}: Updated predicate.
(→‎{{header|AppleScript}}: Added a draft 'selfDescribes' predicate in Applescript)
(→‎{{header|AppleScript}}: Updated predicate.)
Line 128:
on selfDescribes(x)
set s to str(x)
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"}))
1 = (offset of my str(descripn) in s) and ¬
0 = ((items ((length of descripn) + 1) thru -1 of s) as string as integer)
end selfDescribes
 
Line 168 ⟶ 169:
 
-------------------- 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
9,655

edits