title: Learning Scheme, trying to implement map
body: <p>I try to implement map using with fold in Scheme. 
  I referenced this site: [ref1] <a href="http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Towards_a_Standard_Library" rel="nofollow">http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Towards_a_Standard_Library</a>
  The way I understand about fold =>
  left-associate fold (foldl) folds/iterates from the first element. (forwards)
  right-associate fold (foldr) folds/iterates from the last element. (backwards)
  <strong>[Q1] Do I understand correctly?</strong> </p>
  
  <p>From ref1 : the implementation of foldl, foldr</p>
  
  <pre><code> `1) foldl (left-associate fold)`
    (define (foldl func accum lst)
     (if (null? lst)
          accum
          (foldl func (func accum (car lst)) (cdr lst))))
  
  2) foldr (right-associate fold)
   (define (foldr func end lst)
     (if (null? lst)
        end
        (func (car lst) (foldr func end (cdr lst)))))
  </code></pre>
  
  <p>[=>] implement map using fold, ref1 also has map with foldr code, so that's it..</p>
  
  <pre><code>1) map implementation using foldr from ref1.
    (define (map func lst)      
       (foldr (lambda (x y) (cons (func x) y)) '() lst))
  
  **[Q2] map impelementation using foldl from myself** 
    (define (fold-map-left pr list)
      (foldl 
         (lambda (sublist element) (cons (pr element) sublist))
         '() 
         list)
    what I get as the output...
    e.g. (fold-map-left (lambda(n) (expt n n)) '(1 2 3 4)) 
         output =&gt; (256 27 4 1): backwards 
  </code></pre>
  
  <ul>
  <li>I know that left associate fold folds/iterates backwards, so it will take the last first and put it into output..., then what can I do to make the output in right order ? and Is there anything else wrong in my code?</li>
  </ul>