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

33
LINES

< > BotCompany Repo | #1002413 // Turing Tests: List Processing

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1920L/14K/43K).

!759

!include #1002412 // Turing

static void tests() {
  elements();
}

static void elements() {
  repeat 5 {
    L<S> l = randomList();
    add(format3("how many elements are in the list *?", l), l(l));
  }
  
  repeat 2 {
    L<S> l = randomList(2, 4);
    add(format3("what is the first element in the list *?", l), first(l));
    add(format3("what is the last element in the list *?", l), last(l));
    add(format3("what is the 2nd element in the list *?", l), get(l, 1));
  }
}

static L<S> randomList() {
  int n = rand(5);
  ret randomList(n, n);
}

static L<S> randomList(int minLen, int maxLen) {
  int n = minLen + rand(maxLen-minLen+1);
  new L<S> l;
  repeat n { l.add(randomID(1)); }
  ret l;
}

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: #1002413
Snippet name: Turing Tests: List Processing
Eternal ID of this version: #1002413/1
Text MD5: b52ff408c390636e183d1ebdf7bfa2c8
Transpilation MD5: d8c76bd79db67ab7cd1b864504eddb4f
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-20 18:00:25
Source code size: 743 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 647 / 1921
Referenced in: #1002407 - OLD getTuringScore - retrieve Eleu's current "Turing score"
#1002417 - Turing Tests: Command Finding
#1002463 - Turing Tests: Dynamic Questions (added by #1002462)
#3000177 - Answer for stefanreich
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)