Skip to content

Instantly share code, notes, and snippets.

View Iainmon's full-sized avatar
🥶

Iain Moncrief Iainmon

🥶
View GitHub Profile
@Iainmon
Iainmon / dynamic_list.c
Last active February 4, 2021 06:54
This is practice
/* ENTER YOUR FIRST AND LAST NAME: */
/* TO COMPILE: gcc -Wall -ansi -o prog Group1.c */
/* TO RUN, ENTER SIZE OF BAG */
/* FOR EXAMPLE: ./prog 10 */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <assert.h>
struct Link {
int value;
struct Link * next;
};
struct ListStack {
struct Link * sentinel;
@Iainmon
Iainmon / deque.c
Last active January 20, 2021 07:57
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#define TYPE int
struct List {
TYPE val;
struct List* prev;
struct List* next;
#include "../lib/runtime.glsl"
#include "../lib/noise.glsl"
#include "../lib/space.glsl"
#include "../lib/patterns.glsl"
float shape(in vec2 st) {
return sqrt((st.x * st.x) + (st.y * st.y));
}
float lerp(float a, float b, float x) {
data List a = Cons a (List a) | Nil
listA = Cons 0 (Cons 2 (Cons 4 Nil))
listB = Cons 1 (Cons 0 (Cons 1 Nil))
tentothe :: Double -> Double
tentothe m = 10 ** m
reduce :: List Double -> Double -> Double
reduce (Cons n Nil) m = n * (tentothe m)
// Used kernel convolution thinking to solve this one. Take a look!
function linkedList(arr) {
const consLinkedList = value => { return {value: value, next_node: null} }
let head;
let curr;
for (const a of arr) {
if (head == undefined) {
head = consLinkedList(a)
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
sudo chmod a+rw /dev/ttyUSB0
homomorphism :: (a -> b) -> a -> b
homomorphism f a b = f (x * y) == f x <> f y
where f :: a -> b
x = someElement a
y = someElement a
(*) = operation a
(<>) = operation b
homomorphism (\x -> 2 * x) integers evenIntegers
-- Outputs: True
from random import randint
board = []
for x in range(5):
board.append(["O"] * 5)
def print_board(board):
for row in board:
print " ".join(row)