Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc notAdd(a: int, b: int) { | |
return (a + b , a + b); | |
} | |
proc notMul(a: int, b: int) { | |
return (a*b , a*b); | |
} | |
var h = [notAdd, notMul, notAdd, notMul, notAdd]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this method would be super cool in databases for example in a world without GROUP BY sql command :D | |
use Set; | |
use List; | |
use RangeChunk; | |
// takes iterable of object or any stuff | |
// function is the thing that is common between multiple | |
// of some objects in iterable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use RangeChunk; | |
use Time; | |
// serial | |
iter starmap(array, function) { | |
var iterable = array; // I know that I don't need to copy "array" to new variable "iterable" | |
for i in iterable { | |
yield function((...i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use RangeChunk; | |
use Time; | |
iter filter(array, function) { | |
for i in array { | |
if function(i) { | |
yield i; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use RangeChunk; | |
use Time; | |
iter dropwhile(array, function) { | |
var iterable = array; | |
var barrier = false; | |
for i in iterable { | |
if function(i){ | |
barrier = true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use RangeChunk; | |
iter compress(array, trutharray) { | |
for (i,j) in zip(array, trutharray) { | |
if j { | |
yield i; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tobeAdded = (1,2,3); // this would be the input to the partial object | |
proc adds(a:int, b:int, c:int, d:int) { // this is the function which we want to have 10 as constant input | |
return a+b+c+d; // and vary the value of "b", "c", "d" | |
} | |
var constant = 10; // this is "a" | |
writeln(adds(constant,(...tobeAdded))); // a is constant and b, c, d are filled from the expanded tuple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Sort; | |
// partitioning between tasks algorithms | |
// we need to get ALL the permutations of [1,2,3,4,5] so we know | |
// that if we generate them in lexicographical order we would have | |
// [1, 2, 3, 4, 5] as the first permutation and [5, 4, 3, 2, 1] as the last permutation | |
// the partition function do the following: | |
// assume we have 4 tasks we need to distribute the whole lexicographical range of all permutations | |
// into 4 intervals. so assume we insert arr to be [1,2,3,4,5] and numOfTasks to 4 tasks |
NewerOlder