Skip to content

Instantly share code, notes, and snippets.

@cammckinnon
cammckinnon / gist:1329711
Created November 1, 2011 02:55
wlpp scan of copy = new int [size];
ID copy
BECOMES =
NEW new
INT int
LBRACK [
ID size
RBRACK ]
SEMI ;
/* sscanf example */
#include <stdio.h>
int main ()
{
char sentence []="Rudolph is 15 years old";
char str [20];
int i;
sscanf (sentence,"%s is %d",str,&i);
6
BOF
EOF
id
-
(
)
3
S
expr
from itertools import *
from collections import defaultdict
a = 3
b = 6
verts = [(x,y) for x in range(1,a+1) for y in range (1,b+1)]
adjacent = defaultdict(list)
for v1 in verts:
#!/usr/bin/expect -f
set user [lindex $argv 0]
set pass [lindex $argv 1]
set file1 [lindex $argv 2]
set file2 [lindex $argv 3]
spawn scp $file1 $file2 $user@linux.student.cs.uwaterloo.ca:~
expect "*?password:*"
send "$pass\r"
#!/bin/bash
#uw server credentials - careful with these (!!) :
user='username'
pass='password'
#################################
if [ $# -ne 2 -a $# -ne 3 ] ; then
echo "Usage: ./remotelinker.bash file1.merl file2.merl (-verbose)"
exit
fi
<div id="container"> <a href="services.html"><img src="images/top-nav-services.png" id="topnav" usemap="#Map" border="0" />
<map name="Map">
<area shape="rect" coords="23,7,128,43" href="index.html">
<area shape="rect" coords="143,9,259,46" href="services.html">
<area shape="rect" coords="265,5,415,43" href="healthy-meditation.html">
<area shape="rect" coords="425,1,571,56" href="contactus-appt_feedback.html">
<area shape="rect" coords="577,4,679,43" href="faq.html">
<area shape="rect" coords="699,4,854,44" href="employers.html">
</map>
</a> <img src="images/services-banner.png" id="panel" />
#lang racket
;;;;USAGE:
;Modify the lines following comments that begin with MODIFY:
;then run the program to get a proof
;;we use a recursive tree structure for formulas, so that a tree with left node A and right node B means A->B
(define-struct tree (left right not token) #:transparent)
;;create a tree by calling (mtree L R) where L and R are trees
(define (mtree l r)
import re, sys, operator
#read and tokenize the program
tokens = [x for x in re.split(r'\s+', re.sub('([()])', r' \1 ', ''.join((sys.stdin.readlines())))) if x]
#populate the global scope
global_scope = None, {'+': lambda nums: sum(map(apply, nums)), '-': lambda nums: -nums[0]() if len(nums)==1 else nums[0]() - sum(map(apply, nums)[1:]),
'/': lambda nums: nums[0]() / nums[1](), '*': lambda nums: reduce(operator.mul, map(apply, nums)),
'equal?': lambda exprs: 'true' if exprs[0]() == exprs[1]() else 'false',
'if': lambda exprs: exprs[1]() if exprs[0]()=='true' else exprs[2]()}
def ArithGeo(arr):
diff = arr[1] - arr[0]
multiple = arr[1]/arr[0]
isarith = True
isgeom = True
for i in range(0,len(arr)-1):
d = arr[i+1] - arr[i]
if d!=diff:
isarith = False
m = arr[i+1] / arr[i]