Skip to content

Instantly share code, notes, and snippets.

@matxpg
matxpg / gist:fdc8ef288251b34c1935
Created July 5, 2014 06:25
decimal to base conversion
#rem: int, int -> int
#print the remainder of (x/n)
def rem(x,n):
#prevent division by zero
assert(n != 0)
return x % n
def dec2b (xIn,b):
""" Convert n from base 10 (decimal) to base b, printing steps and result. """
assert(b > 1)
@matxpg
matxpg / examples.cpp
Created October 1, 2014 02:02
CMPT-111 demo
//Just run this code in eclipse or whatever you have set up
/* MOST IMPORTANT THINGS I HAVE TO SAY:
* 1: Be careful! There are a lot of SMALL mistakes that can be hard to catch
* eg. every { has a }
* this may cause the program not even to compile and run
* -Every statement has a ; at the end
*
* Mistakes like forgetting a ;
* have caused me to spend hours trying to figure out why seemingly perfect code wasn't working
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
public | t_volunteer | table | cmpt370_group06
public | t_volunteeravailability | table | cmpt370_group06
INSERT into t_volunteer (vol_emailaddress, vol_firstname, vol_surname, vol_phone)
VALUES (getemail,getfirstname, getlastname, getphone);
------------------+--------------+-----------
vol_emailaddress | emailaddress | not null
vol_firstname | firstname | not null
vol_surname | surname | not null
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
C:\Users\matthew\a4\mpg317\problem2>ghci
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :l problem2.hs
[1 of 1] Compiling Main ( problem2.hs, interpreted )
Ok, modules loaded: Main.
*Main> safetail_cond [1, 2, 3