Skip to content

Instantly share code, notes, and snippets.

@et4te
et4te / gist:1063831
Created July 4, 2011 19:34
Reference
;;
;;(in-package :3d-engine)
(in-package :cl-user)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INIT
;;(pushnew "/home/malune/.sbcl/systems/" asdf:*central-registry*)
;;
(asdf:operate 'asdf:load-op :cl-glut)
(asdf:operate 'asdf:load-op :split-sequence)
(asdf:oos 'asdf:load-op :contextl)
(in-package :contextl-user)
(defclass grouped-layer (standard-layer-class) ())
(defgeneric group-root (layer))
(defgeneric default-layer (layer))
(define-layered-method adjoin-layer-using-class
: fizz? ( n -- ? )
3 mod 0 = ;
: buzz? ( n -- ? )
5 mod 0 = ;
: fizzbuzz? ( n -- ? )
@et4te
et4te / luhn-will.lisp
Created August 18, 2011 21:38
solution-less-naive
;;------------------------------------------------------------------------------
(eval-when (:compile-toplevel)
(ql:quickload :series))
(defpackage luhn
(:use :cl :series))
(in-package :luhn)
;;-- sums integer digits as long as x is < 100.
(defparameter *white-colour* #\O)
(defun make-image (m n)
(make-array (list m n) :initial-element *white-colour*))
(defun clear (image)
(loop for i from 0 below (reduce #'* (array-dimensions image)) do
(setf (row-major-aref image i) *white-colour*)))
@et4te
et4te / fwd2.lisp
Created August 27, 2011 20:24
The compiler frontend
;; Examples
;;------------------------------------------------------------------------------
;; 1. non-commands
;; There are two types of 'non-commands',
;; a) integers
;; b) symbols
;;
;; Symbols are looked up, so if you provide an initial environment, with a
;; symbol defined, it will be appropriately looked up.
;; e.g: (lookup 'x '((x . 0))) -> 0
@et4te
et4te / latest-ver.lisp
Created August 27, 2011 23:24
latest version
;; Examples
;;------------------------------------------------------------------------------
;; 1. non-commands
;; There are two types of 'non-commands',
;; a) integers
;; b) symbols
;;
;; Symbols are looked up, so if you provide an initial environment, with a
;; symbol defined, it will be appropriately looked up.
;; e.g: (lookup 'x '((x . 0))) -> 0
@et4te
et4te / deriv.lisp
Created August 29, 2011 15:24
Regex Derivatives
;; base types
(defvar *regex-null* nil)
(defvar *regex-empty* t)
;; predicates
(defun regex-alt? (re)
(and (consp re) (eq (car re) 'alt)))
(defun regex-seq? (re)
(and (consp re) (eq (car re) 'seq)))
(defun regex-rep? (re)
@et4te
et4te / sample.hs
Created August 24, 2015 20:17
Trying to filter the events
processEvent :: NE.NonEmpty ViewEvent -> EventState -> EventState
processEvent trigger (_, ij, nm) =
case NE.head trigger of
Init ->
(Just Refresh, ij, nm)
Prev ->
prevEvent ij nm
Next ->
nextEvent ij nm
@et4te
et4te / Fugly.hs
Created October 2, 2015 00:29
Fugly but working
{-# LANGUAGE JavaScriptFFI #-}
module Scorch.GHCJS.File
(
readFileAsync
) where
import Control.Monad.Trans (liftIO)
import GHCJS.Types
import GHCJS.Foreign
import GHCJS.DOM.File (File)