• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Want to get organized in 2022? Let Dokkio put your cloud files (Drive, Dropbox, and Slack and Gmail attachments) and documents (Google Docs, Sheets, and Notion) in order. Try Dokkio (from the makers of PBworks) for free. Available on the web, Mac, and Windows.


Reference Additions

Page history last edited by PBworks 14 years, 4 months ago

Reference Additions/Corrections





char-alphabetic? char

Returns #t if the character char is in the range #\A to #\Z or #\a to #\z.




make-string k

Returns a new string with a length of k.



1:=> (make-string 3)

; returns an empty string

1:=> (string-length (make-string 5))


1:=> (string-length (string-append "hello" (make-string 5)))



make-string k char

Returns a new string with a length of k filled with the character char.



1:=> (make-string 3 #\a)


1:=> (string-append "hello" (make-string 5 #\space) "world")

hello world


string char

Returns a new string with a length of 1 filled with the character char.

This is equivalent to (make-string 1 char)



1:=> (string #\b)


1:=> (string=? (string #\b) (make-string 1 #\b))



string-ref string k

Returns the character located at index k in the string.



1:=> (string-ref "hello" 0)


1:=> (string-ref "hello" 1)


1:=> (string? (string-ref "hello" 1))


1:=> (char? (string-ref "hello" 1))



string-set! string k char

Sets the character located at index k in the string to char. Returns #unspecified. This function destructively alters a string.



; (define s "hello")

1:=> (string-set! s 1 #\a)


1:=> s


1:=> (string-set! s 0 #\')


1:=> s



A non-destructive version:

(define (string-set-a s k c)
  (string-append (substring s 0 k)
                 (string c)
                 (substring s (+ k 1) (string-length s))))

Another non-destructive version:

(define (string-set-b s k c)
  (let ((new-s (string-copy)))
    (string-set! new-s k c)




sqlite-map sqlite procedure string arg ...


This function can be used to convert returned SQL rows to lists or vectors.


The procedure is applied to each row of the SQL rows returned.




Let's say we have a database full of people and for each person, a name and an age is stored. With sqlite-map we can run a lambda that prints out a sentence stating the name and age of the person.

(sqlite-map *my-database*
  (lambda (name age)
    (print "My name is " name " and I am " age " years old."))
  "SELECT name, age FROM people;")


Now let's say that our table, people, has another column added. Now each and every person has an address column. The previous example will still work because sqlite-map will drop the unused variables when calling the procedure. In the next example, we'll print out all three column values:

(sqlite-map *my-database*
  (lambda (name age address)
    (print "My name is " name ", I am " age
           " years old, and I live at " address "."))
  "SELECT name, age, address FROM people;")

Comments (0)

You don't have permission to comment on this page.