Skip to content

Instantly share code, notes, and snippets.

module LeapYear(isLeapYear) where
isLeapYear :: Int -> Bool
isLeapYear x
| isDivisible 400 = True
| isDivisible 100 = False
| isDivisible 4 = True
| otherwise = False
where isDivisible year = mod x year == 0
@benjic
benjic / TExaS.h
Last active August 29, 2015 14:17
// GistID: 105a8238cde06b80a8a7
#ifndef SYSTICK_FUNC
#define SYSTICK_FUNC
#include "tm4c123gh6pm.h"
#define SYSTICK_TEN_MS_COUNT 800000
// Declare Systick Functions
void SysTick_Init(void);
void SysTick_Wait10ms(unsigned long);
// ***** 0. Documentation Section *****
// main.c for Lab 9
// Runs on LM4F120/TM4C123
// In this lab we are learning functional debugging by dumping
// recorded I/O data into a buffer
// February 21, 2014
// Lab 9
// Jon Valvano and Ramesh Yerraballi
@benjic
benjic / main.c
Last active August 29, 2015 14:16
/*
* A simple implmentation of functions to manipulate an array in C.
*
* GistID: fe4b47db44173247be6f
*/
#include <stdio.h>
#include "UART.h"
#include "TExaS.h"
void EnableInterrupts(void); // Enable interrupts
*Main> :load reverse.hs
[1 of 1] Compiling Main ( reverse.hs, interpreted )
Ok, modules loaded: Main.
*Main> let a = [1..10]
*Main> a
[1,2,3,4,5,6,7,8,9,10]
*Main> reverseList a
[10,9,8,7,6,5,4,3,2,1]
reverseList :: [a] -> [a]
reverseList [] = []
reverseList a = last a : reverseList (init a)
@benjic
benjic / main.c
Created January 25, 2015 23:53
Lab7
// 0.Documentation Section
// Lab7_HeartBlock, main.c
// Runs on LM4F120 or TM4C123 LaunchPad
// Input from PF4(SW1) is AS (atrial sensor),
// Output to PF3, Green LED, is Ready,
// Output to PF1, Red LED, is VT (ventricular trigger)
// Make PF4 input, PF3,PF1 output
// Initialize Ready to high and VT to low
// Repeat this sequence of operation over and over
@benjic
benjic / requester.c
Last active August 29, 2015 14:07
A collection of files related to producer consumer programming models.
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//removed by doug
//#include "message.h"
#include <stdio.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
def addition(a,b):
try:
return a + b
except TypeError:
print("Parameters must be numeric")
def subtraction(a,b):
try:
return b - a
except TypeError: