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 /smlnj-lib/branches/rt-transition/Util/list-map-fn.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/list-map-fn.sml

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

revision 4069, Tue Jun 9 20:52:48 2015 UTC revision 4070, Thu Jun 11 12:33:25 2015 UTC
# Line 1  Line 1 
1  (* list-map-fn.sml  (* list-map-fn.sml
2   *   *
3     * COPYRIGHT (c) 2012 The Fellowship of SML/NJ (http://www.smlnj.org)
4     * All rights reserved.
5     *
6   * COPYRIGHT (c) 1996 by AT&T Research.  See COPYRIGHT file for details.   * COPYRIGHT (c) 1996 by AT&T Research.  See COPYRIGHT file for details.
7   *   *
8   * An implementation of finite maps on ordered keys, which uses a sorted list   * An implementation of finite maps on ordered keys, which uses a sorted list
# Line 243  Line 246 
246            end            end
247      fun mapPartial f l = mapPartiali (fn (_, item) => f item) l      fun mapPartial f l = mapPartiali (fn (_, item) => f item) l
248    
249      (* check the elements of a map with a predicate and return true if
250       * any element satisfies the predicate. Return false otherwise.
251       * Elements are checked in key order.
252       *)
253        fun exists pred = let
254              fun exists' [] = false
255                | exists' ((_, x)::r) = pred x orelse exists' r
256              in
257                exists'
258              end
259        fun existsi pred = let
260              fun exists' [] = false
261                | exists' (arg::r) = pred arg orelse exists' r
262              in
263                exists'
264              end
265    
266      (* check the elements of a map with a predicate and return true if
267       * they all satisfy the predicate. Return false otherwise.  Elements
268       * are checked in key order.
269       *)
270        fun all pred = let
271              fun all' [] = false
272                | all' ((_, x)::r) = pred x andalso all' r
273              in
274                all'
275              end
276        fun alli pred = let
277              fun all' [] = false
278                | all' (arg::r) = pred arg andalso all' r
279              in
280                all'
281              end
282    
283    end (* functor ListMapFn *)    end (* functor ListMapFn *)
284    

Legend:
Removed from v.4069  
changed lines
  Added in v.4070

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