This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FFIStructure subclass: #WuEvent | |
instanceVariableNames: '' | |
classVariableNames: 'OFFSET_BIND_ID OFFSET_ELEMENT OFFSET_EVENT_NUMBER OFFSET_EVENT_TYPE OFFSET_WINDOW' | |
package: 'WebUI'! | |
!WuEvent methodsFor: 'accessing - structure variables' stamp: 'UFFIGenerator 1/4/2024 13:07'! | |
element: anObject | |
"This method was automatically generated" | |
handle pointerAt: OFFSET_ELEMENT put: anObject getHandle.! ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Instead of JSON, encode point of interest data | |
%% as: input([poi(N1, X1, Y1, Z1), ... poi(Nn, Xn, Yn, Zn)]) where Z is the elevation | |
input([poi('Metsäjärvi', 23, 56, 20), | |
poi('Tunturikylä', 78, 12, 120), | |
poi('Sinijärvi', 45, 89, 21), | |
poi('Kallioranta', 34, 67, 19), | |
poi('Karhunpää', 91, 23, 66), | |
poi('Kuusimetsä', 17, 43, 66), | |
poi('Aurinkoniemi', 62, 78, 18), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- use_module(library(dcg/basics)). | |
:- use_module(library(yall)). | |
:- set_prolog_flag(double_quotes, codes). | |
crates(_, []) --> []. | |
crates(Ind, Cs) --> " ", { Ind1 is Ind + 1 }, crates(Ind1, Cs). | |
crates(Ind, [Ind-C|Cs]) --> "[", [Code], "] ", { char_code(C, Code) }, | |
{ Ind1 is Ind + 1}, | |
crates(Ind1, Cs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contiguous([_]). | |
contiguous([[_,E1],[E1,E2]|Segments]) :- | |
contiguous([[E1,E2]|Segments]). | |
% contiguous([[1,3],[3,10],[10,123]]). succeeds | |
% contiguous([[1,3],[420,666]]). fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html> | |
<head> | |
<script src="swipl-bundle.js"></script> | |
<script type="text/prolog"> | |
:- use_module(library(dcg/basics)). | |
:- set_prolog_flag(double_quotes, chars). | |
turtle([]) --> []. % the empty program | |
turtle([Cmd|Cmds]) --> blanks, turtle_command(Cmd), blanks, turtle(Cmds). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.mappy | |
#?(:cljs (:require-macros app.mappy)) | |
(:require #?(:clj [datascript.core :as d]) ; database on server | |
#?(:clj [clojure.data.csv :as csv]) | |
[hyperfiddle.electric :as e] | |
[hyperfiddle.electric-dom2 :as dom] | |
[hyperfiddle.electric-ui4 :as ui] | |
#?(:cljs ["@openlayers-elements/core/ol-map" :as ol-map]) | |
#?(:cljs ["@openlayers-elements/maps/ol-layer-openstreetmap" :as ol-layer-openstreetmap]) | |
#?(:cljs ["@openlayers-elements/core/ol-layer-vector" :as ol-layer-vector]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn render-indexed-values | |
([inspector obj] (render-indexed-values inspector obj 0)) | |
([inspector obj idx-starts-from] | |
(if (every? map? obj) | |
;; Print table instead | |
(let [[_ header1 header2 & rows] (clojure.string/split-lines | |
(with-out-str | |
(clojure.pprint/print-table obj)))] | |
(loop [{counter :counter :as ins} (render-ln inspector header1 header2) | |
obj obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sort-natural [names] | |
(sort-by | |
(fn [name] | |
(mapv (fn [s] | |
(if (every? #(Character/isDigit %) s) | |
(Long/parseLong s) | |
s)) | |
(map second (re-seq #"(\d+|[^\d]+)" name)))) | |
names)) | |
;; (sort-natural ["mun dokkari 13.doc" "mun dokkari 2.doc"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns day20 | |
(:require [clojure.java.io :as io])) | |
(def input (-> "day20.txt" io/reader line-seq)) | |
(def enhance-alg (vec (first input))) | |
(def initial-img | |
(into #{} | |
(mapcat identity) | |
(map-indexed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testArray := #(199 200 208 210 200 207 240 269 260 263). | |
"day1 part 1" | |
part1 := [ :input | | |
| len prev incr | | |
incr := 0. | |
prev := input first. | |
len := input size. | |
2 to: len do: [ :i | | |
(prev < (input at: i)) ifTrue: [ incr := (incr + 1) ]. |
NewerOlder