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
#!/usr/bin/env ruby | |
def process_line(line) | |
if line =~ /(.*):(\d*):(.*)/ then | |
"<a href=\"txmt://open?url=file://#{ENV['TM_DIRECTORY']}/#{$1}&line=#{$2}\">#{$1}:#{$2}: #{$3}</a><br/>" | |
else | |
line + "<br/>" | |
end | |
end | |
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
% Simple Prolog debugging trick | |
:- op(800, fx,'>'). | |
'>'(X) :- | |
write(X), | |
write('\n'), | |
call(X). | |
test :- | |
>write('foobar'). |
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
% Combine several rules into a single one. | |
cl1(a, b, X) :- X is 2+2. | |
cl1(a, c, X) :- X is 4+4. | |
head_condition([],[],true). | |
head_condition([Parameter|RestParams], [RefParam|RestRefParams], (Cond, CondRest)) :- | |
Cond = (RefParam = Parameter), | |
head_condition(RestParams,RestRefParams, CondRest). |
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
:- use_module(library(chr)). | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% This program performs conversions from | |
% regex -> NFA -> DFA | |
% | |
% It consists of three parts: | |
% 1. A regular expression parser (DCG) | |
% 2. A CHR program for converting DCG parse tree to an NFA | |
% 3. A CHR program for converting the NFA to a DFA |
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
#!/usr/bin/env ruby | |
# Point it to the directory where the genbank files are and it will generate | |
# Prolog representations of the files. | |
require 'rubygems' | |
require 'bio' | |
class String | |
def to_prolog | |
"'" + self.gsub("'",'\\\\\'') + "'" |
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
#!/usr/bin/env ruby | |
# Point it to the directory where the genbank files are and it will generate | |
# Prolog representations of the files. | |
require 'rubygems' | |
require 'bio' | |
class String | |
def to_prolog | |
"'" + self.gsub("'",'\\\\\'') + "'" |
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
% A queue data type in CHR with constant time operations. | |
% Needed since this is difficult to do with pure Prolog. | |
:- use_module(library(chr)). | |
:- chr_constraint init_queue/0, enqueue/2, dequeue/1, | |
queue_element/3, queue_start/2, queue_end/2, | |
dequeued_element/2. | |
% The queue is initialized with start=end, first-index=1 |
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
:- use_module(library(chr)). | |
:- set_prolog_flag(chr_toplevel_show_store,false). | |
simplehmm2prism(InputFile,OutputFile) :- | |
read_hmm(InputFile), | |
write_hmm(OutputFile). | |
% These rules are only used as template for creating | |
hmm(L) :- msw(trans(start),S0),hmm(S0,L). |
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
% DFA minimization | |
:- use_module(library(chr)). | |
:- chr_constraint trans/3, state/1, same/2, different/2, final/1, non_final/1, state_order/2. | |
% A simple test DFA for arithmetic expressions | |
test :- | |
final(s3), | |
trans('(', s1, s1), |
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
#!/usr/bin/env ruby | |
# Christian Theil Have, Sep. 2009. | |
require 'rubygems' | |
require 'xmlsimple' | |
class String | |
def to_prolog | |
"'" + self.gsub("'",'\\\\\'') + "'" | |
end |
OlderNewer