31 lines
866 B
Scheme
31 lines
866 B
Scheme
(import (chicken io)
|
|
(chicken process-context)
|
|
(chicken random))
|
|
|
|
(define *api-url* (get-environment-variable "MASTODON_API_URL"))
|
|
(define *access-tolen* (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 (list-nth lines nth)))
|