Skip to content

Instantly share code, notes, and snippets.

View wsgac's full-sized avatar

Wojciech S. Gac wsgac

  • Keepit
  • Warszawa, Poland
View GitHub Profile
@wsgac
wsgac / heap.go
Last active May 20, 2019 13:16
A simple heap implementation in Go
package heap
type HeapIF interface {
Push(el interface{})
Pop() interface{}
Get() interface{}
Size() int64
Empty() bool
}
@wsgac
wsgac / bfs.go
Created May 28, 2019 13:53
Simple implementation of BFS maze-walking in Golang
package bfs
import "container/list"
// Point is a basic structure for representing points in a maze
type Point struct {
x, y int
}
// QPoint wraps around Point together with information about distance from the
@wsgac
wsgac / dfs.go
Created May 29, 2019 11:05
Simple implementation of DFS maze-walking in Golang
package dfs
// Point is a basic structure for representing points in a maze
type Point struct {
x, y int
}
// SPoint wraps around Point together with information about distance from the
// origin
type SPoint struct {
@wsgac
wsgac / timestamp-at-point-to-date.el
Created June 3, 2019 12:36
Interactive Emacs Lisp function for converting timestamps at point to readable form
(defun timestamp-at-point-to-date ()
"Interactively try to capture number at point and convert it to
human-readable date."
(interactive)
(let ((timestamp (/ (thing-at-point 'number) 1000)))
(message (format-time-string "%Y-%m-%dT%T" timestamp))))
@wsgac
wsgac / 99problems.sc
Last active June 6, 2019 15:37
99 Problems in Scala
import scala.annotation.tailrec
// Solutions to 99 Scala problems taken from: http://aperiodic.net/phil/scala/s-99/
// Problem 01
def last(l: List[Any]): Any = {
l match {
case List() =>
null
case List(x) =>
x
@wsgac
wsgac / flatten.go
Last active June 13, 2019 08:00
Flatten arbitrarily nested array in Go
package flatten
import "errors"
// Flatten takes an arbitrarily nested array and tries to
// flatten it into an array of integers. It currently requires
// its input to be in the form of array of interface{}
func Flatten(arr interface{}) ([]interface{}, error) {
res := []interface{}{}
@wsgac
wsgac / Makefile
Last active June 25, 2019 06:38
Port PicoLisp to NetBSD
# 31oct17abu
# (c) Software Lab. Alexander Burger
bin = ../bin
lib = ../lib
ifeq ($(MAKECMDGOALS), arm64.android)
UNAME = Android
MACHINE = aarch64
else
@wsgac
wsgac / vip
Last active June 26, 2019 16:01
Trying to understand the implementation of Vip in PicoLisp
# -*- picolisp -*-
#!/usr/local/bin/picolisp /usr/local/lib/picolisp/lib.l
# 01may18abu
# Annotated version
(load "@lib/misc.l" "@lib/vip.l")
(bye
(if
@wsgac
wsgac / csp.l
Created June 26, 2019 15:59
Concurrency in PicoLisp a'la CSP
(de sequencePrinter (N Key)
(co Key
(yield)
(for i N
(yield i))))
(de sequenceConsumer (Key)
(while (yield Nil Key)
(wait 1000)
(println @)))
@wsgac
wsgac / bfs-test.l
Last active June 30, 2019 08:12
BFS maze-walker in PicoLisp
(load "bfs.l")
(def 'Arr1 '(
(1 1 1 1 1 1)
(1 0 0 0 0 1)
(1 0 9 1 0 1)
(1 0 0 1 1 1)
(1 1 1 1 1 1)))
(test