Sum of first n cubes: Difference between revisions
→{{header|AppleScript}}: Replaced a map-accumulation with a scanning accumulation.
(→Python :: Functional: Replaced map-accumulation with scanning accumulation) |
(→{{header|AppleScript}}: Replaced a map-accumulation with a scanning accumulation.) |
||
Line 63:
script go
on |λ|(a, x)
{v, v}▼
end |λ|
end script
▲ item 2 of mapAccumL(go, 0, enumFromTo(0, n - 1))
end sumsOfFirstNCubes
Line 98 ⟶ 95:
--
on
tell mReturn(f)
set v to startValue
set lng to length of xs
set lst to {startValue}
repeat with i from 1 to lng
set v to |λ|(v, item i of xs, i, xs)
end repeat
return
end tell
end
|