inline lambda issue Topic is solved

Report problems with documented functionality
sirksel
Posts: 222
Joined: 12 Nov 2013, 23:48

inline lambda issue

31 Mar 2018, 22:24

@Lexikos, I LOVE the high-order functions / lambda support you've added. I know some say scope creep... I say pure genius! Love it.

I'm having a little trouble with the following. I've implemented a functional fold method in my custom list class that overrides Array() and []. I won't post that code here, except for the method itself. I think this is the fairly standard fold algorithm:

Code: Select all

 fold(ini, opr) {   ; fold list beginning with ini; applying operation opr sequentially to result of prior
    acu := ini                               ; accumulator gets initial value
    for idx, itm in this                     ; loop list
      acu := opr.call(acu, itm)              ; operation on prior acu and item
    return acu                               ; return final state of accumulator
  }
When I call it, this works:

Code: Select all

  lst := [20,30,10]
  fnc := (a,i) => a+=i
  msgbox lst.fold(5, fnc)
but this doesn't:

Code: Select all

  lst := [20,30,10]
  msgbox lst.fold(5, ((a,i) => a+=i))
It fails with Error: Missing operator or space before "(".
Am I violating a syntax rule by putting the lambda in the fold call directly?

EDIT: msgbox lst.fold(5, (fnc(a,i) => a+=i)) works too...
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: inline lambda issue  Topic is solved

31 Mar 2018, 23:39

Helgef had already reported this issue. It's fixed in v2.0-a092.
sirksel
Posts: 222
Joined: 12 Nov 2013, 23:48

Re: inline lambda issue

01 Apr 2018, 05:40

Apologies for the duplicate. I've tested and can confirm this and similar behavior fixed in v2.0-a092. You're sure quick with the updates. Many thanks.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 20 guests