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> | |
int main(int argc, char *argv[]) { | |
unsigned int i; | |
unsigned int x = 0xdeadbeef; | |
if (argc==2) | |
x = atoi(argv[1]); | |
printf("seed value: %x\n", x); |
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
-- lab-wk3 | |
-- Jeremy.Singer@glasgow.ac.uk | |
-- v1, Thu 5 Oct 23 | |
import Data.Char | |
import Test.QuickCheck | |
{-- | |
1. Write a function `twice` that calls a function f |
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
{- Example code for Functional Programming | |
to demonstrate ad-hoc polymorphism with typeclasses | |
(c) Jeremy Singer 2022 | |
-} | |
data Mammal = Human | Dog | Cat | Pig deriving (Show,Eq) | |
data Reptile = Crocodile deriving (Show,Eq) | |
class Noisy a where | |
mkNoise :: a -> String |
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 Test.QuickCheck | |
import Control.Monad | |
-- simple binary tree, with data stored at leaves | |
data Tree a = Leaf a | Node (Tree a) (Tree a) deriving (Show,Eq) | |
-- only instances of Arbitrary typeclass can be | |
-- generated by QuickCheck random input generator | |
instance Arbitrary a => Arbitrary (Tree a) where | |
arbitrary = sized arbTree |
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 Text.Parsec | |
-- simple datatype for expressions | |
data BinOp = Add | Sub | Mul | Div deriving (Show,Eq) | |
data ArithExpr = | |
Compound ArithExpr BinOp ArithExpr | |
| Value Int | |
deriving Show |
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 io | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
components = [ 'Sensor Interface', | |
'Sensor Node', | |
'Manage Nodes', | |
'Web Interface', | |
'Database Interface', | |
'Communication' |
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 machine import Pin, I2C | |
import time | |
_DEVICE_ADDR = 0x23 # default I2C address for BH1750 light sensor | |
class LightSensor(): | |
#Light Modes | |
OP_SINGLE_HRES1 = 0x20 | |
OP_SINGLE_HRES2 = 0x21 |
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
\documentclass{article} | |
\usepackage{amsmath} | |
\usepackage{fdsymbol} | |
\usepackage[left=1.8cm,top=1.7cm,right=1.8cm,bottom=1.72cm,nohead]{geometry} | |
\begin{document} | |
\thispagestyle{empty} |
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 |
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 [] = [] |
NewerOlder