Skip to content

Instantly share code, notes, and snippets.

View grammarware's full-sized avatar

Vadim Zaytsev grammarware

View GitHub Profile
@grammarware
grammarware / README.md
Last active August 29, 2015 14:09
Wikimedia Hackathon 2014

Beside some smaller discussions, fruitless attempts and minor hacks, these are my main activities at Wikimedia Amsterdam Hackathon 2014.

Wikidata batch import bot

Before coming to the hackathon, I have looked around searching for a topic to find this: @Multichill wanted to refactor several useful but hacky bots he has written in the past, into one generic configurable framework. At the start of the hackathon, I have looked at his code and read through it, but we did not have a chance to act on it. The only thing I can say is that converting this into a framework is definitely possibly, but perhaps not a good task for a hackathon — library design, as any software language engineering activitiy, needs to be done with approp

@grammarware
grammarware / TestPrimes.rsc
Last active August 29, 2015 14:08
Testing Rascal's function for prime numbers
module TestPrimes
import IO;
import math::Util;
bool testprimes()
{
maxint = 104732;
knownprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157,
@grammarware
grammarware / equiv.pl
Created September 7, 2014 10:39
A simple equivalence definition useful for checking if terms are equivalent or for [partial] generation of equivalent terms.
eq('⊇'(A,B), Q) :- eq('⊆'(B,A), Q).
eq('⊆'(A,B),'∀'(X,'→'(LH,RH))) :- xina(X,A,LH), xina(X,B,RH); xnina(X,B,LH), xnina(X,A,RH).
eq('⊆'(A,B),'∀'(X,A,E)) :- xina(X,B,E).
xina(X, A, '∈'(X,A)).
% xina(X, A, '¬'(XA)) :- xnina(X,A,XA).
xina(X, '∪'(A,B), '∨'(XA,XB)) :- xina(X,A,XA), xina(X,B,XB).
xina(X, '∩'(A,B), '∧'(XA,XB)) :- xina(X,A,XA), xina(X,B,XB).
xina(X, '∖'(A,B), '∧'(XA,XB)) :- xina(X,A,XA), xnina(X,B,XB).
xina(X, '∁'(A), XA) :- xnina(X,A,XA).