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.Char | |
x = "the quick brown fox jumps over the lazy dog" | |
y = "it was the best of times, it was the worst of times" | |
z = "to be or not to be" | |
bigrams :: [Char] -> [(Char,Char)] | |
-- generate a list of bigram pairs for a string | |
bigrams sentence = removeNonAlphaChars $ zip sentence $ tail 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
package os.coursework; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
/** | |
* Shortest Job First (SJF) scheduling model |
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> | |
#define BOOT_SECTOR_OFFSET 0 | |
typedef struct { | |
unsigned char jmp[3]; | |
char oem[8]; | |
unsigned short sector_size; |
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 <unistd.h> | |
#define END_OF_LIST (void *)-1 | |
typedef union FreeListCell { | |
union FreeListCell *next; | |
char str[CELL_SIZE_IN_BYTES]; | |
} cell; |
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
mysequence :: (Num a, Ord a) => a -> a -> [a] -> [a] | |
mysequence lower upper accum_list = | |
if upper<lower | |
then accum_list | |
else mysequence lower (upper-1) (upper:accum_list) | |
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
f = open('/usr/share/dict/words') | |
# this is where my dictionary lives on my Mac | |
words = f.read().splitlines() | |
# one word per line | |
f.close() | |
# OS complains if we don't close files | |
def spotTheDifference(myword, properword): |
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 string | |
import urllib.request | |
# download the data from the internet | |
url = 'https://sherlock-holm.es/stories/plain-text/cano.txt' | |
response = urllib.request.urlopen(url) | |
data = response.read() # read the raw bytes | |
text = data.decode('utf-8') # turn the raw data into a Python string | |
words = text.split() |
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 System.Environment (getArgs) | |
main :: IO () | |
main = do | |
args <- getArgs | |
if length args /= 2 | |
then do | |
putStrLn "usage: starman WORD NUM_GUESSES" | |
else | |
let word = args!!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
-- | The 'wordPhrase' function spells out an individual word | |
-- For example, "a is for apple" | |
wordPhrase :: String -> String | |
wordPhrase x = (head x) : " is for " ++ x | |
-- | The 'speller' function generates text for a spelling book | |
-- from a list of words | |
speller :: [String] -> String | |
speller [] = [] |
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
<start> | |
* Items Purchased | |
+ 1 Apple 0.50 | |
+ 2 Apple 0.50 | |
+ 3 Apple 0.50 | |
+ 4 Apple 0.50 | |
+ 5 Apple 0.50 | |
+ 6 Watermelon 3.00 | |
+ 7 Sumatran Coffee Beans 6.00 |
OlderNewer