Skip to content

Instantly share code, notes, and snippets.

Avatar
🍊
Focusing

parthsarthiprasad

🍊
Focusing
View GitHub Profile
View doComp.chpl
use String;
use ByteBufferHelpers;
inline proc doComp(a: ?t1, b: ?t2, c:int, d:int) {
return _strcmp(a.buff+c-1, d-c+1, a.locale_id, b.buff, b.len, b.locale_id) == 0;
}
var i : string = "asdfasdf5";
var j : string = "asdf";
if doComp(i, j, 1, 5)
{writeln(true);}
View horspool_findall.chpl
inline proc findAll(needle: string, region: range(?) = 1:byteIndex..): []
{
/*
find all occurrences of needle in string.
return type :- integer array containing starting indices of matched pattern. (1-based indexing)
empty array if no index found
@parthsarthiprasad
parthsarthiprasad / rn_png.chpl
Created Mar 15, 2020
header file for reading png
View rn_png.chpl
/*****
rw_png_v2.chpl -
Program that reads a PNG file from disk, prints the RGB values found
at one pixel, changes it to 1, 2, 3, and writes the change to disk.
This version accesses the image data directly from Chapel.
Call:
rw_png_v2
--inname=<file> file to read from