Skip to content

Instantly share code, notes, and snippets.

View mmisamore's full-sized avatar

Michael Misamore mmisamore

View GitHub Profile
@mmisamore
mmisamore / gist:5bddbe4658dbdca72292530b7c6e69d8
Last active February 26, 2020 02:10
A simple record generation macro in swi-prolog
:- use_module(library(clpfd)).
% True if TypeFieldFunctor is the functor built from TypeName and FieldName atoms
% with an underscore between
type_field_functor(TypeName, FieldName, TypeFieldFunctor) :-
atom_chars(TypeName, TypeChars),
atom_chars(FieldName, FieldChars),
append(TypeChars, ['_'], TypeUnderscore),
append(TypeUnderscore, FieldChars, TypeFieldFunctorChars),
atom_chars(TypeFieldFunctor, TypeFieldFunctorChars).