Skip to content

Instantly share code, notes, and snippets.

View umanomata's full-sized avatar

Umano Satō umanomata

View GitHub Profile
;;; Program based on example code from composingprograms.com
;;;
;;; - Get a text document from the Web containing works of Shakespeare.
;;; - Count the words in the document and display the result.
;;; - Display the list of words that are six-letters long and that written
;;; backwards form a word that is also included in the document.
;;;
;;; NOTE: This code takes about 9 minutes to run in my machine. This is
;;;
# Program based on example code from composingprograms.com
#
# - Get a text document from the Web containing works of Shakespeare.
# - Count the words in the document and display the result.
# - Display the list of words that are six-letters long and that written
# backwards form a word that is also included in the document.
#
# NOTE: This code takes about 6-8 seconds to run in my machine.
#
scheme@(guile-user)> (use-modules (rnrs io ports) (web client) (web response) (web uri))
scheme@(guile-user)> (define text-url "http://composingprograms.com/shakespeare.txt")
scheme@(guile-user)> (define server-response (http-get (string->uri text-url) #:keep-alive? #true))
scheme@(guile-user)> (get-string-all (response-body-port server-response))
ERROR: In procedure string-index:
ERROR: In procedure string-index: Wrong type argument in position 1 (expecting string): #<eof>
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.