Skip to content

Instantly share code, notes, and snippets.

View tormaroe's full-sized avatar
💭
Doing some Go and then som JavaScript at the moment

Torbjørn Marø tormaroe

💭
Doing some Go and then som JavaScript at the moment
View GitHub Profile
@tormaroe
tormaroe / mål.md
Last active June 1, 2020 16:41
Lær kidden å kode, uke 1

Lær å kode, uke 1

VI skal begynne å lære et programmeringsspråk som heter JavaScript.

Mål for uken:

  1. Forstå hva en variabel er
  2. ForStå hva en funksjon er
  3. Kunne lage og bruke en enkel funksjon
@tormaroe
tormaroe / main.lua
Last active December 6, 2019 07:13
Speed Jumper (löve/Lua 2d game)
--[[
S P E E D J U M P E R
My first löve game (Lua 2d game)
Author: Torbjørn Marø
When: 2019.12.05
Objective: Get the highest score possible by eating green dots as rapidly as
you can manage while avoiding the red mines. Eating several dots in quick
@tormaroe
tormaroe / comp.lang.fsharp.fs
Created October 29, 2019 20:32
comp.lang.fsharp
// Bowling kata
type Spec = { Rolls: int list; Expected: int }
let specs = [
{ Rolls = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]; Expected = 0 }
{ Rolls = [1;2;4;5;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]; Expected = 12 }
{ Rolls = [1;2;4;6;3;4;0;0;0;0;0;0;0;0;0;0;0;0;0;0]; Expected = 23 }
{ Rolls = [5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5]; Expected = 150 }
{ Rolls = [1;2;10;3;4;0;0;0;0;0;0;0;0;0;0;0;0;0;0]; Expected = 27 }
@tormaroe
tormaroe / wrap.js
Created February 13, 2019 14:37
Example code JS
function wrap (text, limit) {
if (text.length > limit) {
// find the last space within limit
var edge = text.slice(0, limit).lastIndexOf(' ');
if (edge > 0) {
var line = text.slice(0, edge);
var remainder = text.slice(edge + 1);
return line + '\n' + wrap(remainder, limit);
}
}
@tormaroe
tormaroe / polymor.py
Created February 13, 2019 14:36
Example code Python 2
class Point(object):
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y
def __repr__(self):
return '<Point 0x%x x: %f y: %f>' % (id(self), self.x, self.y)
class Circle(object):
def __init__(self, center=None, radius=1.0):
self.center = center or Point()
@tormaroe
tormaroe / distribution.py
Created February 13, 2019 14:34
Example code Python
import sys, os
from collections import Counter
def dodir(path):
global h
for name in os.listdir(path):
p = os.path.join(path, name)
if os.path.islink(p):
@tormaroe
tormaroe / recursively.cs
Last active February 13, 2019 14:33
Example code C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace RosettaRecursiveDirectory
{
class Program
{
static IEnumerable<FileInfo> TraverseDirectory(string rootPath, Func<FileInfo, bool> pattern)
@tormaroe
tormaroe / mazeChapter2.go
Created January 10, 2019 20:56
This Go program is a re-implementation of the Ruby code found in Chapter 2 of the book Mazes for Programmers by Jamis Buck.
// Copyright (c) 2019 Torbjørn Marø
//
// This Go program is a re-implementation of the Ruby code found
// in Chapter 2 of the book Mazes for Programmers by Jamis Buck.
// The source contains:
// - General purpose Grid implementation
// - Grid to string function (ASCII maze)
// - Grid to PNG function (using gg package)
// - Binary Tree maze generation algorithm
// - Sidewinder maze generation algorithm
@tormaroe
tormaroe / euler1.apl
Last active December 12, 2019 09:22
Project Euler problem #1 solved in APL
⍝ This is my very first APL program,
⍝ made from scratch using an APL primer at
⍝ http://aplwiki.com/LearnApl/BuiltInFunctions
⍝ Evaluated using http://tryapl.org/
⍝ Yields the sum of all multiples of 3 or 5 below 1000.
n←⍳999⋄a←+/n×0=3|n⋄b←+/n×0=5|n⋄c←+/n×0=15|n⋄a+b-c
⍝ Second version using a function definition..
f←{+/⍺×0=⍵|⍺}⋄n←⍳999⋄a←n f 3⋄b←n f 5⋄c←n f 15⋄a+b-c
@tormaroe
tormaroe / maze1.lisp
Last active March 12, 2017 09:39
Maze experiments with common lisp and processing.js, part I (garbled)
(dolist (x '(:hunchentoot :cl-who :parenscript :cl-fad))
(ql:quickload x))
(defpackage "EXPERIMENTS"
(:use "COMMON-LISP" "HUNCHENTOOT" "CL-WHO" "PARENSCRIPT" "CL-FAD"))
(in-package "EXPERIMENTS")