This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* lexical grammar */ | |
| %lex | |
| %% | |
| \s+ /* skip whitespace */ | |
| [0-9]+("."[0-9]+)?\b return 'NUMBER' | |
| \"([^\\\"]|\\.)*\" return 'STRING_LITERAL' | |
| "forall" return 'forall' | |
| "copy_term" return 'copy_term' | |
| "if" return "if" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- initialization(main). | |
| :- set_prolog_flag('double_quotes','chars'). ;this is for SWI-Prolog | |
| :- use_module(library(chr)). | |
| :- chr_constraint type/2. | |
| type(A,B) \ type(A,B) <=> true. | |
| type((A;B),C) ==> C = bool,type(A,bool),type(B,bool). | |
| type((A,B),C) ==> C = bool,type(A,bool),type(B,bool). | |
| type(A>B,C) ==> C = bool,type(A,number),type(B,number). | |
| type(A<B,C) ==> C = bool,type(A,number),type(B,number). | |
| type(A+B,C) ==> C = number,type(A,number),type(B,number). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import copy | |
| import sys | |
| import subprocess | |
| def matches_pattern(string,pattern): | |
| if len(string) != len(pattern): | |
| return False | |
| for i in range(0,len(string)): | |
| if is_expr_(pattern[i]): | |
| for j in range(0,len(string)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import copy | |
| import sys | |
| import subprocess | |
| from tokenize import tokenize | |
| from io import BytesIO | |
| def tokenize_input(the_input): | |
| return ([a.string for a in list(tokenize(BytesIO(the_input.encode('utf-8')).readline)) if a.string not in ["\n","","utf-8"]]) | |
| def matches_pattern(string,pattern): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- initialization(main). | |
| :- set_prolog_flag(double_quotes,chars). | |
| main :- recursive_partial_eval((is_between(3,4,5) -> false,is_between(1,C,3);is_between(3,4,5);is_between(3,D,4)),B),writeln(B). | |
| recursive_partial_eval(A,B) :- | |
| find_all_clauses_(A,A1), | |
| (A==A1,A1=B;recursive_partial_eval(A1,B)). | |
| find_all_clauses_(A,A) :- var(A). | |
| find_all_clauses_(A,B) :- nonvar(A),find_all_clauses(A,B). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- initialization(main). | |
| :- set_prolog_flag('double_quotes','chars'). | |
| main :- Term = (member(Z,A),append(A,B,C),dif(A,[true,false])),has_type(Term:Type,Types),writeln('Term with types to infer:'),writeln(Term),writeln('Types of variables in this term:'),writeln(Types). | |
| greater_than(A,B) :- | |
| A > B. | |
| matches_any_([],B) :- false. | |
| matches_any_([A|A1],B) :- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Search redirector | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author Anderson Green | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //I wish there were a better way to do this! | |
| #define func(type,name,param1,param2,body) type name(type param1,type param2) {body} | |
| #define generic(name,param1,param2,body) func(float,name,param1,param2,body) func(vec2,name,param1,param2,body) func(vec3,name,param1,param2,body) func(vec4,name,param1,param2,body) | |
| //define two "generic" functions using this macro | |
| generic(add,a,b, | |
| return a + b; | |
| ) | |
| generic(sub,a,b, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const replaceOnce = require('replace-once'); | |
| var str = 'I have a cat, a cathy, and a catch.'; | |
| var find = ['cat', 'cathy', 'catch']; | |
| var replace = ['catch', 'catch', 'cathy']; | |
| console.log(replaceOnce(str, find, replace, 'gi')); | |
| //=> 'I have a catch, a catchhy, and a catchch.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(helloworld). | |
| -import(lists,[append/2]). | |
| -export([start/0]). | |
| replace_if_match(X) -> | |
| case X of | |
| [A, "equals", B | Tail ] -> | |
| [[A,"==",B],replace_if_match(Tail)]; | |
| [A, "is", B | Tail ] -> | |
| [[A,"==",B],replace_if_match(Tail)]; |