Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1011132 // rcurry - curry a function, supplying arguments from the back

JavaX fragment (include)

static O mapLike rcurry(fO f, fO arg) {
  int n = numberOfFunctionArguments(f);
  if (n == 0) fail("function takes no arguments");
  if (n == 1) ret new F0 {
    O get() {
      ret callF(f, arg);
    }
  };
  if (n == 2)
    ret new F1 {
      O get(O a) {
        ret callF(f, a, arg);
      }
    };
  throw todo("currying a function with " + n + "arguments");
}

Author comment

Began life as a copy of #1008681

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011132
Snippet name: rcurry - curry a function, supplying arguments from the back
Eternal ID of this version: #1011132/2
Text MD5: 86ecaa172ece5b00560109d22711a30b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-07 18:41:54
Source code size: 380 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 399 / 462
Version history: 1 change(s)
Referenced in: [show references]