Initial commit
This commit is contained in:
commit
dc3eab173c
5 changed files with 1559 additions and 0 deletions
31
main.scm
Normal file
31
main.scm
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(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)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue