Skip to content

Instantly share code, notes, and snippets.

View MitchCarroll's full-sized avatar
💭
A million little projects

C. Mitch Carroll MitchCarroll

💭
A million little projects
  • INL
  • Idaho Falls, ID
View GitHub Profile

% A Guide to Rust Syntax

A very brief guide to Rust syntax. It assumes you are already familiar with programming concepts.

Assert macro

The assert! macro ends the program if the condition passed to it is not true:

fn main() {
@MitchCarroll
MitchCarroll / wolfram.scm
Last active December 22, 2015 17:59
wolfram rule iterator in scheme
(define bool-to-binary (lambda (n) (map (lambda (x) (if (equal? x #t) 1 0)) n)))
(define binary-to-bool (lambda (n) (map (lambda (x) (if (= x 1) #t #f)) n)))
(define binary
(lambda (number bits)
(if (= bits 0) '()
(begin
(let*
((b (if (>= number (expt 2 (- bits 1))) 1 0))
(v (if (= b 1) (- number (expt 2 (- bits 1))) number)))
@MitchCarroll
MitchCarroll / amb-conic.scm
Last active December 19, 2015 06:09
Non-deterministic conic fitting. runs something like 320,000,000 iterations to determine a conic section which fits a set of data points.
;; The following definition for amb, assert and other operators are from Teach Yourself Scheme in Fixnum Days by Dorai Sitaram.
(define amb-fail '())
(define initialize-amb-fail
(lambda ()
(set! amb-fail
(lambda ()
(error "amb tree exhausted")))))
@MitchCarroll
MitchCarroll / gist:4588917
Created January 21, 2013 20:16
factorial.lisp
(defun ! (n)
(if (= n 0) 1
(* n (! (- n 1)))))