Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
puts ARGV.map {|x| x += '@tcd.ie'}.join(', ')
bool has_left_recursion(Grammar g) {
for (vector<Rule>::iterator i = g.rules.begin(); i != g.rules.end(); ++i) {
if (i->mother == i->dtrs.front()) return true;
}
return false;
}
public static int[] countLetters(String input) {
int[] results = new int[26];
for (int i = 0; i < input.length(); i++) {
int cur = input.toLowerCase().charAt(i);
if (cur >= 'a' && cur <= 'z') {results[cur - 'a']++;}
}
return results;
}
#!/usr/bin/env ruby
def y(n)
case n
when 0 then 1
when 1 then 0
when 2 then -4
when 3 then 0
else y(n - 4)
end
array2string(a : ARRAY[G]) : STRING is
local
k : INTEGER
do
Result := "<< "
from
k := a.lower
until
k = a.upper
loop
/**
* As described in 'updates' in the nodes
*/
void CHART::do_cell(int i, int k) {
Rule r;
Category A, B, C;
int A_included, B_included;
ón __todhchaí__ impórtaigh roinnt
#!/usr/bin/env ruby
def mel(f)
include Math
(1000.quo(Math.log(2))) * Math.log(1 + (f.quo(1000)))
end
1.upto(1000) do |f|
puts "#{f} Hz --> #{mel(f).round(1)} mel"
end
digraph CYK_parse {
rankdir=LR;
node [shape = point,height=0.3]; 0,1,2,3,4,5,6;
// k = 1
// --------------------
0 -> 1 [label = "DET",color=black];
0 -> 1 [label = "the",color=red];
q = lambda l : l if len(l) <= 1 else (q([x for x in l[1:] if x < l[0]]) + [l[0]] + q([x for x in l[1:] if x >= l[0]]))