Jump to content

Pangram checker: Difference between revisions

(→‎{{header|AppleScript}}: Small adjustment)
Line 185:
From OSX 10.10 onwards, we can, however, use ObjC functions from AppleScript by importing the Foundation framework. We do this below to get a toLowerCase() function. If we also add generic filter and map functions, we can write and test a simple isPangram() function as follows:
 
<lang AppleScript>use framework "Foundation" -- ( for case conversion function )
 
on run
map(isPangram, {¬
"is this a pangram", ¬
"The quick brown fox jumps over the lazy dog"})
end run
 
-- isPangram :: String -> Bool
on isPangram(s)
lengthscript of ¬charUnUsed
property lowerCaseString : my toLowerCase(s)
filter(mClosure(my charUnused, ¬
{lowerCaseString:toLowerCase(s)}), ¬
on "abcdefghijklmnopqrstuvwxyz"lambda(c) = 0
{lowerCaseString:toLowerCase(s)}), ¬does not contain c
end lambda
end script
length of filter(charUnUsed, "abcdefghijklmnopqrstuvwxyz") = 0
end isPangram
 
 
-- charUnUsed :: Character -> Bool
-- TEST
on charUnused(c)
 
my closure's lowerCaseString does not contain c
on run
end charUnused
map(isPangram, {¬
"is this a pangram", ¬
"The quick brown fox jumps over the lazy dog"})
--> {false, true}
end run
 
 
Line 276 ⟶ 282:
end if
end unwrap
 
</lang>
 
{{Out}}
 
<prelang AppleScript>{false, true}</prelang>
 
=={{header|AutoHotkey}}==
9,659

edits

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