-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.q
More file actions
31 lines (28 loc) · 770 Bytes
/
list.q
File metadata and controls
31 lines (28 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
///
// same as Python's range function with two parameters
.list.range: {[start; stop]
:start + til stop - start;
};
///
// same as Python's range function with three parameters
.list.steprange: {[start; stop; step]
:start + step * til (stop - start) div step;
};
///
// returns a new list in which parameter obj is inserted at position index of list l
// similar to Python's list.insert function except that it does no modify list inplace
.list.insert: {[l; index; obj]
:#[index; l], obj, index _ l;
};
///
// pops last element from the list and returns last element
// same as Python's list.pop function
//
// example usage:
// l: til 5;
// .list.pop `l
.list.pop: {[l]
obj: last value l;
l set -1_value l;
:obj;
};