Jump to content

Magic squares of doubly even order: Difference between revisions

m
→‎{{header|AppleScript}}: ( slightly simpler name-binding in isPowerOf() )
m (→‎{{header|AppleScript}}: ( slightly simpler name-binding in isPowerOf() ))
Line 146:
set v to k
script remLeft
property divisor : k
on lambda(x)
x mod (remLeft's divisor)v is not 0
end lambda
end script
script integerDiv
property divisor : k
on lambda(x)
x div (integerDiv's divisor)v
end lambda
end script
Line 183 ⟶ 181:
end tell
end map
 
-- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
on zipWith(f, xs, ys)
set nx to length of xs
set ny to length of ys
if nx < 1 or ny < 1 then
{}
else
set lng to cond(nx < ny, nx, ny)
set lst to {}
tell mReturn(f)
repeat with i from 1 to lng
set end of lst to lambda(item i of xs, item i of ys)
end repeat
return lst
end tell
end if
end zipWith
 
-- cond :: Bool -> a -> a -> a
9,659

edits

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