Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/mlton/list.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/mlton/list.sml

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

revision 3862, Sun May 15 15:44:30 2016 UTC revision 3863, Sun May 15 17:18:04 2016 UTC
# Line 11  Line 11 
11    
12      include LIST      include LIST
13    
14        val appi : (int * 'a -> unit) -> 'a list -> unit
15      val mapi : (int * 'a -> 'b) -> 'a list -> 'b list      val mapi : (int * 'a -> 'b) -> 'a list -> 'b list
16    
17      val revMap : ('a -> 'b) -> 'a list -> 'b list      val revMap : ('a -> 'b) -> 'a list -> 'b list
# Line 22  Line 23 
23    
24      open List      open List
25    
26        fun appi f xs = let
27              fun appf ([], _) = ()
28                | appf (x::xs, i) = (f (i, x); appf (xs, i+1))
29              in
30                appf (xs, 0)
31              end
32    
33      fun mapi f xs = let      fun mapi f xs = let
34            fun mapf ([], _, ys) = List.rev ys            fun mapf ([], _, ys) = List.rev ys
35              | mapf (x::xs, i, ys) = mapf (xs, i+1, f(i, x)::ys)              | mapf (x::xs, i, ys) = mapf (xs, i+1, f(i, x)::ys)

Legend:
Removed from v.3862  
changed lines
  Added in v.3863

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