Problems

Call Me Once

MediumClosures & Scope

Implement once(fn) — the wrapped function runs only on the first call; later calls return the first result. Input: a JSON array of numbers passed to a once-wrapped triple. Print the JSON array of returned values.

Input: one JSON array. Output: one JSON array (every entry equals triple of the FIRST input).

Your program reads from stdin and prints to stdout.

Example 1

Input: [2,5,9]

Output: [6,6,6]

Hints

JavaScriptClosures