0

Since last week, mapping a function of more than one arguments over result from ee.List.sequence using 'bind' no longer works although it can be mapped over a regular list. Why? e.g.

// simple function

var add_x = function(n, x) {
  return n + x;
}

**// This command returns expected result

print([1,2,3,4,5].map(add_x.bind(null,10)));

[11,12,13,14,15]

**// This command results in an error

print(ee.List.sequence(1,5,1).map(add_x.bind(null,10)));

List (Error)
List.map: A mapped algorithm must take one argument.
  • 1
    What do "no longer work" and "this throws error" mean? Make sure to read over https://stackoverflow.com/help/how-to-ask and edit this question to include relevant error messages. – Andy Ray Apr 13 '21 at 23:03

1 Answers1

0

This looks like a bug to me. (I've reported it.) Until it's fixed, you can replace bind with a handwritten version for add_x in particular:

var add_x = function(n, x) {
  return ee.Number(n).add(x);
}

var bind_add_x = function(n) {
  return function (x) {
    return add_x(n, x);
  }
}

print(ee.List.sequence(1,5,1).map(bind_add_x(10)));
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
  • The proposal to use currying solves the problem but does not address the underlying issue of an error when using 'bind' for functions mapped over ee.List.sequence but no error when mapped over a ee.List as both return as ee.List() as input to the mapped function. – Richard Fernandes Apr 15 '21 at 19:23
  • @RichardFernandes Yes, this is only a workaround for the bug. – Kevin Reid Apr 15 '21 at 20:12