Skip to content

Instantly share code, notes, and snippets.

View j-walk's full-sized avatar

Johnathan j-walk

View GitHub Profile
import Prelude hiding (lex)
import Data.Char
import Data.Foldable (sequenceA_)
import Control.Monad.State
data Token = Num Integer
| Op Char deriving (Show, Eq)
@j-walk
j-walk / forth
Created February 17, 2019 02:24
function classify(str)
if tonumber(str) == nil then
return str
else
return tonumber(str)
end
end
#include <stdio.h>
void get_coins(int a) {
int quarters = a / 25; a %= 25;
int dimes = a / 10; a %= 10;
int nickles = a / 5; a %= 5;
int pennies = a;
printf( " quarters: %d\n dimes: %d\n nickles: %d\n pennies: %d\n"
@j-walk
j-walk / LCReducer.hs
Created September 4, 2018 03:56
Lambda Calculus reducer
data Expr = DeBruijn Int
| App Expr Expr
| Lambda Expr deriving Show
eval :: Expr -> Expr
eval (App (Lambda body) arg) = (arg `captureIn` body) 0
eval (App (App lhs rhs) arg) = eval $ App (eval (App lhs rhs)) arg
eval a = a
extern crate sdl2;
extern crate noise;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Rect;
use noise::{NoiseModule, Perlin};
use noise::Seedable;
use std::io;
fn main() {
let mut stdin = io::stdin();
let input = &mut String::new();
input.clear();
println!("Specific impulse: ");
stdin.read_line(input).unwrap();
let specific_impulse = input.trim().parse::<i32>().unwrap();
use std::io;
fn main() {
let mut stdin = io::stdin();
let input = &mut String::new();
input.clear();
println!("Specific impulse: ");
stdin.read_line(input).unwrap();
let specific_impulse = input.trim().parse::<i32>().unwrap();
#[inline(three_and_five)]
fn three_and_five() -> usize {
(1..1000).filter(|x| { x % 3 == 0 || x % 5 == 0 }).sum()
}
#[inline(fib)]
fn fib() -> usize {
struct Fib {
curr : usize,
next : usize,
extern crate image;
extern crate num;
use std::fs::File;
use std::path::Path;
use num::Complex;
// a function which takes a borrowed Complex<f32> and checks if its within
// the bounds of the mandelbrot set
[package]
name = "MandelbrotImage"
version = "0.1.0"
authors = ["Johnathan Walker <jhwalking0@gmail.com>"]
[dependencies]
image = "*"
num = "*"