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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
/*************************************************************************** | |
* Helper Types | |
***************************************************************************/ | |
/* Basic example person data structure. */ |
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
-- Insertion sort | |
inssort :: Ord a => [a] -> [a] | |
inssort [] = [] | |
inssort (x:xs) = insert x (inssort xs) | |
where | |
insert :: Ord a => a -> [a] -> [a] | |
insert n [] = [n] | |
insert n (x:xs) | |
| n <= x = n : x : xs | |
| otherwise = x : insert n 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
-- Question 1: Define the functions add and allEqual | |
add :: (Int -> Int) -> Int -> Int | |
add f 1 = f 1 | |
add f n = if n > 0 then add f (n-1) + f n else error "input must be n > 0" | |
allEqual :: (Int -> Int) -> Int -> Bool | |
allEqual f 1 = True | |
allEqual f n = if n > 0 then (allEqual f (n-1)) && (f (n-1) == f n) else error "input must be n > 0" |
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 Data.List | |
type NI = Int | |
type Age = Int | |
type Balance = Int | |
type Person = (NI, Age, Balance) | |
type Bank = [Person] | |
type Market = [Bank] | |
type Pop = [NI] |
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
type Name = String | |
type Customer = (Name, Int, Int, Int) | |
type VStore = [Customer] | |
-- BEGIN TEST DATA -- | |
cust1 :: Customer | |
cust1 = ("Neil", 311, 271, 345) | |
cust2 :: Customer |
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
/** | |
* The Central Processing unit (CPU). | |
* Consists of an ALU and a set of registers, designed to fetch and | |
* execute instructions written in the Hack machine language. | |
* In particular, functions as follows: | |
* Executes the inputted instruction according to the Hack machine | |
* language specification. The D and A in the language specification | |
* refer to CPU-resident registers, while M refers to the external | |
* memory location addressed by A, i.e. to Memory[A]. The inM input | |
* holds the value of this location. If the current instruction needs |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#define DEFAULT_TAB_STOP 4 | |
#define DEFAULT_REPLACE ' ' // used as tab replacement | |
int main(int argc, char *argv[]) { | |
char *arg_end; | |
int c, tab_stop, curr_col, spaces; |
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
#include <stdio.h> | |
#define MAXLINE 1000 | |
#define NEWLINE_ON 1 | |
#define NEWLINE_OFF 0 | |
int strend(char string[], int len); | |
int getline(char line[], int maxline); | |
int main(void) { |
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
#include <stdio.h> | |
#define BUF_SIZE 256 | |
void reverse(char dst[], char src[], int len); | |
int strend(char string[], int len); | |
int getline(char line[], int maxline); | |
int main(void) { | |
int len; |
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
#!/usr/bin/env python | |
from os import listdir, mkdir | |
from os.path import isfile, join | |
from shutil import move | |
PATH = "D:/Videos/Movies/" | |
def main(): | |
files = [ f for f in listdir(PATH) if isfile(join(PATH, f)) ] |
NewerOlder