Unverified Commit 3a1b1555 authored by Philip Kaludercic's avatar Philip Kaludercic 🌝
Browse files

fixed ordering bug

parent 6b5db779
......@@ -13,22 +13,16 @@
See (haunt builder blog)'s blog for more details."
(define (shorter-than lst n)
(cond ((null? lst) (positive? n))
((zero? n) (null? lst))
(else (shorter-than (cdr lst) (1- n)))))
(define (group-by lst n)
(cond ((null? lst) '())
((shorter-than lst n)
(list lst))
(receive (head rest) (split-at lst n)
(cons head (group-by rest n))))))
(let loop ((left n) (current '()) (groups '()) (rest lst))
(cond ((null? rest) (reverse! (cons current groups)))
((> left 0) (loop (1- left) (cons (car rest) current)
groups (cdr rest)))
(else (loop n '() (cons (reverse! current) groups) rest)))))
(lambda (site posts)
(let* ((sorted (posts/reverse-chronological posts))
(grouped (group-by posts per-page))
(grouped (group-by (reverse sorted) per-page))
(last-group-nr (length grouped)))
(define (create-index-page group i)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment