Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View z5h's full-sized avatar
🕳️

Mark Bolusmjak z5h

🕳️
View GitHub Profile
@z5h
z5h / example.pl
Created December 6, 2023 06:00
"Monte-Carlo amb" in Prolog, proof of concept
amb_example(BestGuess) :-
run_with_monte_carlo_amb(1000,
( amb(BestGuess, [2,3,4,5,6,7,8,9,10,11,12]),
guess_the_dice_total(BestGuess)
)).
guess_the_dice_total(Total) :-
random_member(Dice1, [1,2,3,4,5,6]),
random_member(Dice2, [1,2,3,4,5,6]),
(Total =\= Dice1 + Dice2 -> amb(fail); true).
@z5h
z5h / Kernel.elm
Created May 8, 2023 14:35
Updated microKanren Kernel
-- modified version of https://package.elm-lang.org/packages/dvberkel/microkanren/latest/
-- fixing a bug, and adding reification, some practical features, and an example logic problem
module MicroKanren.Kernel exposing
( Goal, State, Stream(..), Term(..), Var
, callFresh, conjoin, disjoin
, emptyState, unit
, walk
, Substitutions, fish, l, pull, unify, v
)
; Stumbling towards Y
;
; The applicative-order Y combinator is a function that allows one
; to create a recursive function without using define.
; This may seem strange. Usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the
; Y combinator (in Scheme).
@z5h
z5h / Example.elm
Last active November 23, 2020 13:10
Elm focusout focusin
import Browser.Dom
import Element exposing (Element)
import Element.Background as Background
import Element.Border as Border
import Element.Font as Font
import Element.Input as Input
import Html
import Html.Attributes
import Html.Events
import Json.Decode as Decode
@z5h
z5h / Main.elm
Created February 1, 2020 16:27
transition animations
module Main exposing (..)
import Browser
import Html exposing (Html, button, div, span, text)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Timeline exposing (Timeline)
module Base.ListSet exposing
( Set
, diff
, empty
, filter
, foldl
, foldr
, fromList
, group
, insert
@z5h
z5h / Example.elm
Last active December 20, 2018 14:08
autofocus in Elm that actually works
input [
focus (item.id) (RequiresFocus_ Nothing)
else
none
]
@z5h
z5h / ycombinator.clj
Created March 6, 2013 20:25
Applicative-Order Y Combinator (Clojure Version)
; Stumbling towards Y (Clojure Version)
;
; (this tutorial can be cut & pasted into your IDE / editor)
;
; The applicative-order Y combinator is a function that allows one to create a
; recursive function without using define.
; This may seem strange, because usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the Y combinator.
@z5h
z5h / StickierDiv.jsx
Last active November 17, 2016 13:46
sticky header div react js
/** @jsx React.DOM */
"use strict";
var util = {
// findPos() by quirksmode.org
// Finds the absolute position of an element on a page
findPos: function (obj) {
var curleft = 0,
curtop = 0;
import Stopwatch
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)
main: Program Never
main =
App.program
{ init = init