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

fixed ordering bug

parent 6b5db779
...@@ -13,22 +13,16 @@ ...@@ -13,22 +13,16 @@
listing. listing.
See (haunt builder blog)'s blog for more details." 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) (define (group-by lst n)
(cond ((null? lst) '()) (let loop ((left n) (current '()) (groups '()) (rest lst))
((shorter-than lst n) (cond ((null? rest) (reverse! (cons current groups)))
(list lst)) ((> left 0) (loop (1- left) (cons (car rest) current)
(else groups (cdr rest)))
(receive (head rest) (split-at lst n) (else (loop n '() (cons (reverse! current) groups) rest)))))
(cons head (group-by rest n))))))
(lambda (site posts) (lambda (site posts)
(let* ((sorted (posts/reverse-chronological 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))) (last-group-nr (length grouped)))
(define (create-index-page group i) (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