Skip to content

Instantly share code, notes, and snippets.

View omar-3's full-sized avatar
🔫

Omar omar-3

🔫
View GitHub Profile
@omar-3
omar-3 / example3COUNT.chpl
Last active April 2, 2020 17:16
why don't you just use range? :")
use RangeChunk;
// serial
iter count(start: int, step: int, end: int) {
for i in start..end by step do
yield i;
}
@omar-3
omar-3 / example2LRU_Cache.chpl
Last active April 1, 2020 00:21
A very simple implementation of LRU caching utility like the one in python functools
private use Map only;
private use List only;
private use Crypto only;
record ordered_map {
/* Type of map keys.*/
type keyType;
/* Type of map values*/
@omar-3
omar-3 / example1StarMap.chpl
Created March 27, 2020 00:46
serial and parallel implementation of iterator starmap in Chapel
use RangeChunk only;
// serial
iter starmap(array, function) {
var iterable = array;
for i in iterable {
yield function((...i)); // tuple expansion ... THANK YOU CHAPEL
}
}
@omar-3
omar-3 / LRU_caching.chpl
Created March 18, 2020 21:45
a very not-merged-pull-request implementation for lru_cache utility from fuctools in Chapel
private use Map only;
private use List only;
private use Crypto only;
record ordered_map {
/* Type of map keys.*/
type keyType;
/* Type of map values*/
type valType;
use Sort;
var sentialPermutation = [42];
// return true if the two arrays are equal
proc isEqual(a, b) : bool {
for (i, j) in zip(a,b) {
if i != j {
use Sort;
var sentialPermutation = [42];
// return true if the two arrays are equal
proc isEqual(a, b) : bool {
for (i, j) in zip(a,b) {
if i != j {
@omar-3
omar-3 / functional.chpl
Last active April 10, 2020 06:45
a very very short itertools-ish module
/* Support for functional programming capabilities in Chapel
Provides a different number of generators and iterators inspired
by Python, and other functional programming languages: APL, Haskell, Scala.
*/
module functional {