code: function unfoldr(f) {
      return function(x) {
        var result = [];
        for (var m = f (x); m.isJust; m = f (m.value.snd)) {
          result.push (m.value.fst);
        }
        return result;
      };
    }
docs: # unfoldr :: (b -> Maybe (Pair a b)) -> b -> Array a . . Takes a function and a seed value, and returns an array generated by . applying the function repeatedly. The array is initially empty. The . function is initially applied to the seed value. Each application . of the function should result in either: . .   - Nothing, in which case the array is returned; or . .   - Just a pair, in which case the first element is appended to .     the array and the function is applied to the second element. . . ```javascript . > S.unfoldr (n => n < 1000 ? S.Just (S.Pair (n) (2 * n)) : S.Nothing) (1) . [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] . ```