Magic squares of doubly even order: Difference between revisions
Content added Content deleted
m (→{{header|AppleScript}}: ( slightly simpler name-binding in isPowerOf() )) |
|||
Line 146: | Line 146: | ||
set v to k |
set v to k |
||
script remLeft |
script remLeft |
||
property divisor : k |
|||
on lambda(x) |
on lambda(x) |
||
x mod |
x mod v is not 0 |
||
end lambda |
end lambda |
||
end script |
end script |
||
script integerDiv |
script integerDiv |
||
property divisor : k |
|||
on lambda(x) |
on lambda(x) |
||
x div |
x div v |
||
end lambda |
end lambda |
||
end script |
end script |
||
Line 183: | Line 181: | ||
end tell |
end tell |
||
end map |
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 |
-- cond :: Bool -> a -> a -> a |