Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Idorobots / gist:2393695
Created April 15, 2012 16:27
Monadic Templates in D
import std.typecons;
template MakeNumberedValue(alias tag, alias val) {
enum MakeNumberedValue = tuple(tag, val);
}
template NumberedValue(alias tv) {
enum NumberedValue = tv[1];
}
@Idorobots
Idorobots / gist:2722167
Created May 17, 2012 23:01
2d Markov localization template
;; Lokalizacja Markov'a
;; SKN Noesis 21.05.2012
(defparameter *world-map* '((red green green)
(green green green)
(green green green)))
(defparameter *measurement-prob* 0.7)
(defparameter *movement-success-prob* 0.8)
(defparameter *movement-fail-prob* 0.1)
@Idorobots
Idorobots / gist:2722172
Created May 17, 2012 23:03
1d Markov localization template
;; Lokalizacja Markov'a
;; SKN Noesis 21.05.2012
(defparameter *world-map* '(green red green green))
(defparameter *measurement-prob* 0.7)
(defparameter *movement-success-prob* 0.8)
(defparameter *movement-fail-prob* 0.1)
(defun prior-prob ()
"Funkcja zwraca początkowy rozkład prawdopodobieństwa dla podanego świata."
@Idorobots
Idorobots / gist:2855718
Created June 1, 2012 23:25
SKN Noesis Particle Filters template
;; SKN Noesis
;; 04.06.2012
;; Parametry symulacji
; Rozmiar swiata
(defconstant +world-size+ 100.0)
; Punkty orientacyjne i poczatkowa pozycja robota
(defparameter *landmarks* '((20.0 . 20.0) (80.0 . 80.0) (20.0 . 80.0) (80.0 . 20.0)))
@Idorobots
Idorobots / gist:2938338
Created June 15, 2012 19:32
Pearson corelation in assembly
# Params:
.equ x, 8
.equ y, 12
.equ n, 16
# Data:
.data
xm: .double 0.0
ym: .double 0.0
@Idorobots
Idorobots / 1main.d
Created July 16, 2012 17:09
Common Lisp loop in the D programming lanugage (WIP)
import std.algorithm;
import std.stdio;
import std.typecons;
import cl.loop;
void main(string[] args) {
args = args[1 .. $]; // Get rid of the process name.
int[] array = [1, 2, 3, 4, 5];
@Idorobots
Idorobots / loop.lisp
Created July 20, 2012 16:31
Common Lisp LOOP example and output
(let ((random (loop with max = 500
for i from 0 to max
collect (random max))))
(loop for i in random
counting (evenp i) into evens
counting (oddp i) into odds
summing i into total
maximizing i into max
minimizing i into min
finally (format t "Stats: ~A"
@Idorobots
Idorobots / loop.d
Created July 20, 2012 16:33
Common Lisp LOOP in the D programming language
auto random = mixin(Loope!q{
with max = 500
for i from 0 to max
collect $$ uniform(0, max) $$
});
mixin(Loop!q{
for i in random
counting $$ (i&1) == 0 $$ into evens
counting $$ (i&1) == 1 $$ into odds
@Idorobots
Idorobots / gist:3151731
Created July 20, 2012 16:37
Common Lisp LOOP in D programming language - generated code
auto random = (() {
auto max = 500;
auto __i_0 = max;
auto i = 0;
typeof(uniform(0, max))[] __accumulator;
for(;;) {
if(i >= __i_0) break;
__accumulator ~= uniform(0, max);
@Idorobots
Idorobots / complex.d
Created July 20, 2012 18:09
Complex Loop
auto random = randomStuff(); // Implemented elswhere. ;)
auto result = mixin(Loope!q{
initially $$ writeln("Loop test:"); $$
with isEven = $$ (uint x) => ((x&1) == 0) $$
with updateAnalysis = $$ // A D function analysing our data.
(uint[] stats) {
static count = 0;
if(count++ % 10 == 0)