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

20
LINES

< > BotCompany Repo | #1008681 // curry - curry a function

JavaX fragment (include)

1  
static O mapLike curry(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  
    toString { ret "curry(" + f + ", " + sfu(arg) + ")"; }
10  
  };
11  
  if (n == 2)
12  
    ret new F1 {
13  
      O get(O a) {
14  
        ret callF(f, arg, a);
15  
      }
16  
      
17  
      toString { ret "curry(" + f + ", " + sfu(arg) + ")"; }
18  
    };
19  
  throw todo("currying a function with " + n + "arguments");
20  
}

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: #1008681
Snippet name: curry - curry a function
Eternal ID of this version: #1008681/8
Text MD5: b0b5cdaffd2b90c968225a1d40bec999
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-07 16:40:01
Source code size: 515 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 668 / 664
Version history: 7 change(s)
Referenced in: [show references]