VI skal begynne å lære et programmeringsspråk som heter JavaScript.
- Forstå hva en variabel er
- ForStå hva en funksjon er
- Kunne lage og bruke en enkel funksjon
--[[ | |
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 |
// 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 } |
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); | |
} | |
} |
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() |
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): |
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) |
// 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 |
⍝ 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 |
(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") |