Libraryless. Click here for Pure Java version (1920L/14K/43K).
1 | !759 |
2 | |
3 | !include #1002412 // Turing |
4 | |
5 | static void tests() { |
6 | elements(); |
7 | } |
8 | |
9 | static void elements() { |
10 | repeat 5 { |
11 | L<S> l = randomList(); |
12 | add(format3("how many elements are in the list *?", l), l(l)); |
13 | } |
14 | |
15 | repeat 2 { |
16 | L<S> l = randomList(2, 4); |
17 | add(format3("what is the first element in the list *?", l), first(l)); |
18 | add(format3("what is the last element in the list *?", l), last(l)); |
19 | add(format3("what is the 2nd element in the list *?", l), get(l, 1)); |
20 | } |
21 | } |
22 | |
23 | static L<S> randomList() { |
24 | int n = rand(5); |
25 | ret randomList(n, n); |
26 | } |
27 | |
28 | static L<S> randomList(int minLen, int maxLen) { |
29 | int n = minLen + rand(maxLen-minLen+1); |
30 | new L<S> l; |
31 | repeat n { l.add(randomID(1)); } |
32 | ret l; |
33 | } |
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: | 728 / 2028 |
Referenced in: | [show references] |