34 lines
942 B
Scheme
34 lines
942 B
Scheme
(import (chicken io)
|
|
(chicken process-context)
|
|
(chicken random)
|
|
(chicken format))
|
|
|
|
(define *api-url* (get-environment-variable "MASTODON_API_URL"))
|
|
(define *access-token* (get-environment-variable "MASTODON_ACCESS_TOKEN"))
|
|
|
|
(define (file-lines file-path)
|
|
(let ((file (open-input-file file-path)))
|
|
(let loop ((lines '())
|
|
(cur (read-line file)))
|
|
(if (eof-object? cur)
|
|
(begin (close-input-port file)
|
|
(reverse lines))
|
|
(loop (cons cur lines)
|
|
(read-line file))))))
|
|
|
|
(define lines (file-lines "./words.txt"))
|
|
|
|
(define (list-nth ls n)
|
|
(if (zero? n)
|
|
(car ls)
|
|
(list-nth (cdr ls) (- n 1))))
|
|
|
|
(define (list-remove-nth ls n)
|
|
(if (zero? n)
|
|
(cdr ls)
|
|
(cons (car ls) (list-remove-nth (cdr ls) (- n 1)))))
|
|
|
|
(let ((nth (pseudo-random-integer (length lines))))
|
|
(display "Seize the means of ")
|
|
(display (list-nth lines nth))
|
|
(display "\n"))
|