Skip to content

Instantly share code, notes, and snippets.

View kamahen's full-sized avatar

Peter Ludemann kamahen

View GitHub Profile
@kamahen
kamahen / d_wire.pl
Created July 18, 2021 14:59
Test data for protobufs:proto_meta_field_name/4 indexing
wire_codes(RequestWireStream) :-
RequestWireStream=[10,16,100,101,115,99,114,105,112,116,111,114,46,112,114,111,116,111,26,8,8,3,16,17,24,3,34,0,122,185,133,3,10,16,100,101,115,99,114,105,112,116,111,114,46,112,114,111,116,111,18,15,103,111,111,103,108,101,46,112,114,111,116,111,98,117,102,34,77,10,17,70,105,108,101,68,101,115,99,114,105,112,116,111,114,83,101,116,18,56,10,4,102,105,108,101,24,1,32,3,40,11,50,36,46,103,111,111,103,108,101,46,112,114,111,116,111,98,117,102,46,70,105,108,101,68,101,115,99,114,105,112,116,111,114,80,114,111,116,111,82,4,102,105,108,101,34,228,4,10,19,70,105,108,101,68,101,115,99,114,105,112,116,111,114,80,114,111,116,111,18,18,10,4,110,97,109,101,24,1,32,1,40,9,82,4,110,97,109,101,18,24,10,7,112,97,99,107,97,103,101,24,2,32,1,40,9,82,7,112,97,99,107,97,103,101,18,30,10,10,100,101,112,101,110,100,101,110,99,121,24,3,32,3,40,9,82,10,100,101,112,101,110,100,101,110,99,121,18,43,10,17,112,117,98,108,105,99,95,100,101,112,101,110,100,101,110,99,121,24,10,32,3,40,5,82,16,112,117,98,10
@kamahen
kamahen / coverage.pl
Created July 12, 2021 17:57
Hack on top of swipl library(test_cover) for more granular coverage
% -*- mode: Prolog -*-
/*
TODO: generalize this code to work in any file (currently, file name is hard-coded)
This code depends on a modification to ~/src/swipl-devel/packages/plunit/test_cover.pl:
$ git diff
diff --git a/test_cover.pl b/test_cover.pl
index 5290499..24d8874 100644
@kamahen
kamahen / tree_path.pl
Last active March 8, 2021 19:44
calculate path into a binary tree for some element
% -*- mode: Prolog -*-
% See https://twitter.com/krismicinski/status/1368611779107053570?s=03
% gives a program in Racket; I've written my version in
% non-deterministic Prolog.
% Tested with SWI-Prolog 8.3.20
% (You can also try this out at https://swish.swi-prolog.org/)
% The problem is (using Racket terminology):