Skip to content

Instantly share code, notes, and snippets.


Justin Meiners justinmeiners

View GitHub Profile
View Age of empires II AI Scripting
; The official HD AI
; An Artificial Intelligence Script written by Archon and Promiskuitiv
; Get in contact with Promiskuitiv by sending a mail to
; List of taunts it reacts to:
; Standard taunts.
; 33 - Stop slinging resources. If slinging is requested early and is immediately canceled it may mess up the strategy.
; 38 - Sling Resources. Human player only, stops any unit production except for civilian units.
View foldBinary.swift
func foldBinary<T>(_ list: [T], operation: (T, T) -> T) -> T? {
if let initial = list.first {
return list.dropFirst().reduce(initial, operation)
} else {
return nil
(defun arrangements (n k)
(if (= n 0)
(list nil)
(when (< k n)
(mapcar (lambda (tail)
(cons 0 tail))
(arrangements (- n 1) k)))
View mode.cpp
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
template<typename I>
std::pair< typename std::iterator_traits<I>::value_type, size_t> mode(I start, I end) {
typedef typename std::iterator_traits<I>::value_type V;
if (start == end) {
(defun digits-to-val (digits)
(reduce (lambda (acc x)
(+ (* 10 acc) x)) digits))
(defun val-to-digits (x)
(if (< x 10)
(list (mod x 10))
(cons (mod x 10)
(val-to-digits (floor x 10)))))
justinmeiners / sicm-mit-scheme.Dockerfile
Last active Nov 26, 2020
MIT Scheme + Structure and Interpretation of Classical Mechanics libraries (scmutils).
View sicm-mit-scheme.Dockerfile
# Dockerfile
# MIT Scheme + Structure and Interpretation of Classical Mechanics libraries (scmutils).
# For REPL. Launch with -it for a tty.
# For script. docker run -v ${PWD}/scripts:/scripts scm --quiet --load /scripts/test.scm
FROM alpine:3.12.1
RUN apk add --no-cache \
build-base \
linux-headers \
(defun compact-duplicates (vector cmp)
(prog ((i 1)
(j 1)
(N (length vector))
(x (aref vector 0)))
(if (not (funcall cmp (aref vector i) x))
(setf x (aref vector i))
; my own sin and cos functions using taylor seris
(defun eval-poly (coef x)
; horners method
(prog* ((i (- (length coef) 1))
(acc (aref coef i)))
(decf i)
(if (< i 0) (return acc))
(setf acc (+ (aref coef i) (* x acc)))
; code translated from
; note that theirs actually has an off by one error
(defun integer-sqrt (n)
(prog ((shift 2) (result 0))
(declare (fixnum n shift result))
(if (< n 2) (return n))
(if (not (= (ash n (- shift)) 0))
(defun group-adjacent (list &key (test #'eql))
(lambda (group x)
(if (or (funcall test (car group) x) (funcall test x (car group)))
(push group result)
(list x))
(cons x group)))
(cdr list)