Skip to content

Instantly share code, notes, and snippets.


Peter Ludemann kamahen

View GitHub Profile
kamahen / pcre2_mingw.c
Created Apr 5, 2022
Output some PCRE2 values for debugging PCRE2 with MinGW
View pcre2_mingw.c
#include <stdio.h>
#include <pcre2.h>
static void config_uint(const char *descr, uint32_t flag) {
uint32_t value;
uint32_t len = pcre2_config_8(flag, NULL);
int rc = pcre2_config_8(flag, &value);
if (rc >= 0) {
printf("%s (len=%d rc=%d) 0x%08x: 0x%08x\n", descr, len, rc, flag, value);
:- det(valid_termpos/2).
%! valid_termpos(+Term, +TermPos) is semidet.
% Checks that a Term has an appropriate TermPos.
% This should always succeed:
% read_term(Term, [subterm_positions(TermPos)]),
% valid_termpos(Term, TermPos)
valid_termpos(_Term, Var), var(Var) => true. % trivial default: "unknown" position
valid_termpos(Atom, _From-_To), atom(Atom) => true.
valid_termpos(Number, _From-_To), number(Number) => true.
valid_termpos(Var, _From-_To), var(Var) => true.
kamahen /
Created Jul 18, 2021
Test data for protobufs:proto_meta_field_name/4 indexing
wire_codes(RequestWireStream) :-
kamahen /
Created Jul 12, 2021
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/
$ git diff
diff --git a/ b/
index 5290499..24d8874 100644
kamahen /
Last active Mar 8, 2021
calculate path into a binary tree for some element
% -*- mode: Prolog -*-
% See
% 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
% The problem is (using Racket terminology):