Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/system/Basis/Implementation/list.sml
ViewVC logotype

Diff of /sml/trunk/system/Basis/Implementation/list.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3416, Thu Jul 9 16:14:26 2009 UTC revision 3417, Thu Jul 9 16:19:33 2009 UTC
# Line 1  Line 1 
1  (* list.sml  (* list.sml
2   *   *
3   * COPYRIGHT (c) 1995 AT&T Bell Laboratories.   * COPYRIGHT (c) 2009 The Fellowship of SML/NJ (http://www.smlnj.org)
4     * All rights reserved.
5   *   *
6   * Available (unqualified) at top level:   * Available (unqualified) at top level:
7   *   type list   *   type list
8   *   val nil, ::, hd, tl, null, length, @, app, map, foldr, foldl, rev   *   val nil, ::, hd, tl, null, length, @, app, map, foldr, foldl, rev
9     *   exception Empty
10   *   *
11   * Consequently the following are not visible at top level:   * Consequently the following are not visible at top level:
12   *   val last, nth, take, drop, concat, revAppend, mapPartial, find, filter,   *   val last, nth, take, drop, concat, revAppend, mapPartial, find, filter,
13   *       partition, exists, all, tabulate   *       partition, exists, all, tabulate
  *   exception Empty  
14   *   *
15   * The following infix declarations will hold at top level:   * The following infix declarations will hold at top level:
16   *   infixr 5 :: @   *   infixr 5 :: @
# Line 31  Line 32 
32    
33      exception Empty = Empty      exception Empty = Empty
34    
35      (* these functions are implemented in base/system/smlnj/init/pervasive.sml *)
36      val null = null      val null = null
37      val hd = hd      val hd = hd
38      val tl = tl      val tl = tl
39        val length = length
40        val rev = rev
41        val op @ = op @
42        val foldr = foldr
43        val foldl = foldl
44        val app = app
45        val map = map
46    
47      fun last [] = raise Empty      fun last [] = raise Empty
48        | last [x] = x        | last [x] = x
# Line 66  Line 75 
75              if n >= 0 then loop (l,n) else raise Subscript              if n >= 0 then loop (l,n) else raise Subscript
76            end            end
77    
     val length = length  
     val rev = rev  
     val op @ = op @  
78    
79      fun concat [] = []      fun concat [] = []
80        | concat (l::r) = l @ concat r        | concat (l::r) = l @ concat r
# Line 76  Line 82 
82      fun revAppend ([],l) = l      fun revAppend ([],l) = l
83        | revAppend (h::t,l) = revAppend(t,h::l)        | revAppend (h::t,l) = revAppend(t,h::l)
84    
     val app = app  
     val map = map  
   
85      fun mapPartial pred l = let      fun mapPartial pred l = let
86            fun mapp ([], l) = rev l            fun mapp ([], l) = rev l
87              | mapp (x::r, l) = (case (pred x)              | mapp (x::r, l) = (case (pred x)
# Line 103  Line 106 
106                  else loop(t, trueList, h::falseList)                  else loop(t, trueList, h::falseList)
107            in loop (l,[],[]) end            in loop (l,[],[]) end
108    
     val foldr = foldr  
     val foldl = foldl  
109    
110      fun exists pred = let      fun exists pred = let
111            fun f [] = false            fun f [] = false

Legend:
Removed from v.3416  
changed lines
  Added in v.3417

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0