Skip to content

Instantly share code, notes, and snippets.

View lokedhs's full-sized avatar

Elias Mårtenson lokedhs

View GitHub Profile
(defun compute-font-dpi ()
(let* ((display (clim-clx:clx-port-display (clim:find-port)))
(db (xlib:root-resources (xlib:display-default-screen display)))
(res (xlib:get-resource db :|dpi| :|Dpi| '(:xft) '(:|Xft|)))
(default-sizes '(:normal 14 :tiny 8 :very-small 10 :small 12 :large 18 :very-large 20 :huge 24)))
(when res
(alexandria:when-let ((font-size (parse-integer res :junk-allowed t)))
(let* ((default-dpi 96)
(font-scale (/ font-size default-dpi)))
(setq climi::+font-sizes+
$ ./waf configure
reinitialized logger
subdirectories dir = ['wscript']
extensions subdirs = []
Running init() - this constructs the matrix of legal waf operation names
Setting top to : /home/elias/src/clasp
Setting out to : /home/elias/src/clasp/build
cfg.options.enable_mpi = None
configure()
cfg.env.ENABLE_MMTK = []
data class SelectedArea(val x: Int, val y: Int, val width: Int, val height: Int) {
companion object {
fun computeSelectedArea(selectedCells: ObservableList<TablePosition<*, *>>): SelectedArea? {
if (selectedCells.size == 0) {
return null
}
val minCol = selectedCells.minOf { it.column }
val maxCol = selectedCells.maxOf { it.column }
val minRow = selectedCells.minOf { it.row }
data class SelectedArea(val x: Int, val y: Int, val width: Int, val height: Int) {
companion object {
fun computeSelectedArea(selectedCells: ObservableList<TablePosition<*, *>>): SelectedArea? {
if (selectedCells.size == 0) {
return null
}
val cols = selectedCells.groupBy { p -> p.column }.entries.sortedBy { e -> e.key }.map { e -> e.value }
val rows = selectedCells.groupBy { p -> p.row }.entries.sortedBy { e -> e.key }.map { e -> e.value }
(defun zn-factor-generators (m) ;; m > 1
(let* (($intfaclim)
(fs (sort (get-factor-list m) #'< :key #'car))
(pe (car fs))
(p (car pe)) (e (cadr pe))
(a (expt p e))
phi fs-phi ga gs ords fs-ords pegs )
;; lemma 1, page 98 :
;; (Z/mZ)* is cyclic when m =
(when (= m 2) ;; 2
(defun rischexpvar (expexpflag flag l)
(prog (lcm y m p alphar beta gamma delta r s
tt denom k wl wv i ytemp ttemp yalpha f a expg n yn yd)
(desetq (f a expg n) l)
(cond ((or (pzerop a) (pzerop (car a)))
(return (cond ((null flag) (rzero))
(t (rischzero))))))
(setq denom (ratdenominator f))
(setq p (findpr (cdr (partfrac a mainvar))
(cdr (partfrac f mainvar))))
(defun map-subseq (fn seq &optional start end from-end)
"Helper function to map SEQ between START and END."
(declare (type (or null array-index) start end)
(optimize (debug 0) (safety 1)
(compilation-speed 0)))
;; (when (and start end)
;; (assert (<= start end)))
(let ((start (or start 0))
(fn (ensure-function fn)))
(fbind (fn)
(defmethod tess-begin-polygon ((tess tessellator) &optional (polygon-data nil))
(let* ((polygon-data-id
(or (loop for value being the hash-values of (polygon-data tess)
using (hash-key key)
when (eq value polygon-data)
return key)
(hash-table-count (polygon-data tess))))
(foreign-key (foreign-alloc :uint64 :initial-contents (list (id tess) polygon-data-id))))
(setf (gethash polygon-data-id (polygon-data tess)) polygon-data)
∇ solvePart1 {
content ← ⊃ {⍎¨ ↓ "^([0-9]+),([0-9]+) -> ([0-9]+),([0-9]+)$" regexp:finderror ⍵}¨ io:read "part05.txt"
⍝ Compute size of array
width ← 1+⌈/,content[;0 2]
height ← 1+⌈/,content[;1 3]
xcoords ← ((⍋⊇⊢)⍤1) content[;0 2]
ycoords ← ((⍋⊇⊢)⍤1) content[;1 3]
∇ solvePart1 {
stringToNumbers ⇐ {⍎¨ ⍵ ⊂⍨ ⍺≠⍵}
filecontent ← io:read "part04.txt"
num ← @, stringToNumbers ↑filecontent
b ← ⊃ {⊃ (↑" ") stringToNumbers¨ ⍵}¨ v ⊂⍨ (⊂⍬) ≢¨ v←2↓filecontent
⍝ Compute the time at which each cell is picked, 0 means that the cell was not picked
indexed ← (1+⍳≢num) ×⌺ (⍴b)⍴1
res ← +⌿ indexed × num=⌺b