RosettaCodeData/Task/100-doors/AppleScript/100-doors-5.applescript

22 lines
449 B
AppleScript
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
-- perfectSquaresUpTo :: Int -> [Int]
on perfectSquaresUpTo(n)
script squared
-- (Int -> Int)
2017-09-23 10:01:46 +02:00
on |λ|(x)
2016-12-05 22:15:40 +01:00
x * x
2017-09-23 10:01:46 +02:00
end |λ|
2016-12-05 22:15:40 +01:00
end script
set realRoot to n ^ (1 / 2)
set intRoot to realRoot as integer
set blnNotPerfectSquare to not (intRoot = realRoot)
2017-09-23 10:01:46 +02:00
map(squared, enumFromTo(1, intRoot - (blnNotPerfectSquare as integer)))
2016-12-05 22:15:40 +01:00
end perfectSquaresUpTo
on run
perfectSquaresUpTo(100)
end run