Skip to content

Instantly share code, notes, and snippets.

View superfunc's full-sized avatar
🎟️
play dodonpachi

superfunc

🎟️
play dodonpachi
View GitHub Profile
for(vector<int>::iterator itr = people.begin(); itr != people.end(); itr++) {
// do something
}
template <typename T>
auto makeSomething(T& t) -> decltype(t.makeSomething()) {
auto thing = t.makeSomething();
// edit thing's properties
return thing;
}
@superfunc
superfunc / examreview.md
Last active August 29, 2015 14:07
EECS 168 Exam Review

EECS 168 Exam I Review

Variables

A variable declaration has three basic parts.

TYPE NAME = VALUE;
{-# LANGUAGE GADTs, KindSignatures #-}
data Tree :: * where
Leaf :: Int -> Tree
Node :: Tree -> Tree -> Tree
deriving (Show,Eq,Ord)
-- Write a function that sums the leaf values in a tree
summation :: Tree -> Int
summation (Leaf v) = v
summation (Node l r) = (summation l) + (summation r)
@superfunc
superfunc / gist:36242904c2b7b10b0bd5
Created October 29, 2014 06:58
Maybe type in Nim
# An implementation of the Maybe monad for Nim
# This implements the traditional operations, bind(called chain)
# and return(called box) as well as a few useful operators for
# cleaning up usage of the monad. Also implemented the functor
# operation fmap(called map) which allows a procedure to be called
# on a wrapped value
type
Maybe*[T] = object
case valid*: bool
@superfunc
superfunc / labexamreview.md
Last active August 29, 2015 14:08
EECS 168 Lab Exam Review

EECS 168, Lab Exam Review

Disclaimer: This is not a comprehensive review. It is to help you emphasize important sections, but it is your responsibility to review all previous labs and relevant chapters in the text.

Format of the exam

  • You will be allowed to use your textbooks, and eclipse. But you will not be able to discuss with one another, use your old labs, or access the internet.
@superfunc
superfunc / conkyrc
Created November 14, 2014 05:09
conkyrc
# Use Xft?
use_xft yes
xftfont Trebuchet MS:size=8
xftalpha 0.8
text_buffer_size 2048
# Up interval in seconds
update_interval 1
# This is the number of times Conky will update before quitting.
@superfunc
superfunc / bubble.java
Created November 17, 2014 16:39
Bubble sort example
// Sample algorithm, lab 11: bubble sort
// Josh Filstrup, GTA EECS Dept @ KU
// November 17th, 2014
public class bubble {
// A function to swap two elements of an array
public static void swap(int[] xs, int i, int j) {
// Create a temporary value so we don't lose
// it when assigning to xs[i] in the next line.
int tmp = xs[i];
@superfunc
superfunc / gist:f98c09be26f195f05ab6
Created December 10, 2014 23:42
Java file io example
import java.io.BufferedReader;
import java.io.FileReader;
public class test {
public static void main(String[] args) {
// We must put bufferedIO type work in a try-catch block
// because it could throw an exception.
try {
// Create a new buffered reader object,

DPLL Algorithm

Input: A formula in CNF

Output: Either "satisfiable" or "unsatisfiable".

Performance: O(2n), Space: O(n)

image