Reputation: 761
I'm taking a functional programming course, using the book SICP as reference. Several places in the book, I have come across the use of '->' arrows in procedure definitions.
Examples:
(define (segments->painter segment-list)
(lambda ...
(define (tree->list tree)
(if (...
(define (scheme-number->complex n)
(make-complex-from-real ...
So, what does the '->' arrow mean? Is it a naming convention to indicate that the procedure transforms one thing into another; such as tree-into-list? If not; what does the arrow represent?
Thanks!
Upvotes: 2
Views: 3362
Reputation: 31145
As @sepp2k mentions -> is part of the name and doesn't mean anything in it self.
The convention is to use -> in names for "conversion" (used loosely) functions.
The function string->list
has a string as input and produces a list of characters.
In most cases you can pronounce ->
as "to". That is string->list
is pronounced "string to list" if you were to read code aloud.
Upvotes: 5
Reputation: 370367
Is it a naming convention to indicate that the procedure transforms one thing into another; such as tree-into-list?
Exactly.
Upvotes: 4