Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View parthsarthiprasad's full-sized avatar
🍊
Focusing

parthsarthiprasad

🍊
Focusing
View GitHub Profile
@parthsarthiprasad
parthsarthiprasad / rn_png.chpl
Created March 15, 2020 19:58
header file for reading png
/*****
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
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
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);}