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)

1  
static O mapLike rcurry(fO f, fO arg) {
2  
  int n = numberOfFunctionArguments(f);
3  
  if (n == 0) fail("function takes no arguments");
4  
  if (n == 1) ret new F0 {
5  
    O get() {
6  
      ret callF(f, arg);
7  
    }
8  
  };
9  
  if (n == 2)
10  
    ret new F1 {
11  
      O get(O a) {
12  
        ret callF(f, a, arg);
13  
      }
14  
    };
15  
  throw todo("currying a function with " + n + "arguments");
16  
}

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: 401 / 464
Version history: 1 change(s)
Referenced in: [show references]