Changeset 14026 in project for chicken


Ignore:
Timestamp:
04/01/09 05:41:39 (11 years ago)
Author:
Kon Lovett
Message:

Added make-list, take & drop. Renamed -1 to /1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/chicken-primitive-object-inlines.scm

    r14011 r14026  
    671671                 (find-elm (%cdr ls) ls) ) ) ) )
    672672
    673 (define-inline (%list-fold-1 func init ls0)
     673(define-inline (%list-fold/1 func init ls0)
    674674  ;(assert (and (proper-list? ls0) (procedure? func)))
    675675  (let loop ((ls ls0) (acc init))
     
    677677        (loop (%cdr ls) (func (%car ls) acc)) ) ) )
    678678
    679 (define-inline (%list-map-1 func ls0)
     679(define-inline (%list-map/1 func ls0)
    680680  ;(assert (and (proper-list? ls0) (procedure? func)))
    681681  (let loop ((ls ls0))
     
    683683        (%cons (func (%car ls)) (loop (%cdr ls))) ) ) )
    684684
    685 (define-inline (%list-for-each-1 proc ls0)
     685(define-inline (%list-for-each/1 proc ls0)
    686686  ;(assert (and (proper-list? ls0) (procedure? proc)))
    687687  (let loop ((ls ls0))
     
    689689      (proc (%car ls))
    690690      (loop (%cdr ls)) ) ) )
     691
     692(define-inline (%make-list n e)
     693  (let loop ((n n) (ls '()))
     694    (if (%fxzero? n) ls
     695        (loop (%fxsub1 n) (%cons e ls)) ) ) )
     696
     697(define-inline (%list-take ls0 n)
     698  (let loop ((ls ls0) (n n))
     699    (if (%fxzero? n) '()
     700        (%cons (%car ls) (loop (%cdr ls) (%fxsub1 n))) ) ) )
     701
     702(define-inline (%list-drop ls0 n)
     703  (let loop ((ls ls0) (n n))
     704    (if (%fxzero? n) ls
     705        (loop (%cdr ls) (%fxsub1 n)) ) ) )
    691706
    692707;; Structure (wordblock)
Note: See TracChangeset for help on using the changeset viewer.