This file contains 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
def squareList(xs: List[Int]): List[Int] = xs match { | |
case Nil => xs | |
case y :: ys => y * y :: squareList(ys) | |
} | |
def squareList1(xs: List[Int]): List[Int] = | |
xs map (y => y * y) |
This file contains 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 math.Ordering | |
def msort[T](xs: List[T])(implicit ord: Ordering[T]): List[T] = { | |
val n = xs.length / 2 | |
if (n == 0) xs | |
else { | |
def merge(xs: List[T], ys: List[T]): List[T] = | |
(xs, ys) match { | |
case (Nil, ys) => ys | |
case (xs, Nil) => xs |
This file contains 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
> emacs thing.cpp | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
template <class T> | |
class Node { | |
public: | |
Node* right; |
This file contains 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
from collections import Counter | |
import re | |
from sklearn.feature_extraction import DictVectorizer | |
from sklearn.feature_extraction.text import TfidfTransformer | |
from sklearn.feature_extraction.text import CountVectorizer | |
from itertools import islice, tee | |
from nltk.corpus import stopwords | |
def tokenize(sentence): | |
words = re.findall("[a-zA-Z]+", sentence) |
This file contains 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
from itertools import islice, tee | |
from nltk.corpus import stopwords |
This file contains 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
from math import sqrt | |
import sys | |
from collections import defaultdict | |
from itertools import izip | |
class Point(object): | |
def __init__(self, x, y, id=None): | |
self.x = x | |
self.y = y |
This file contains 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 glob | |
import get_data | |
import run_knn | |
from math import * | |
__author__ = 'Robert Griesmeyer' | |
__date__ = 'May 21st 2011' | |
__doc__ = """ This module is for the use of accuaracy checking of the\ | |
k-nearest neighbor algorithm execution. The parts tested are the predictions\ |