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/int-list-map.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/int-list-map.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  (* int-list-map.sml  (* int-list-map.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 integer keys, which uses a sorted list   * An implementation of finite maps on integer keys, which uses a sorted list
# Line 241  Line 244 
244            end            end
245      fun mapPartial f l = mapPartiali (fn (_, item) => f item) l      fun mapPartial f l = mapPartiali (fn (_, item) => f item) l
246    
247      (* check the elements of a map with a predicate and return true if
248       * any element satisfies the predicate. Return false otherwise.
249       * Elements are checked in key order.
250       *)
251        fun exists pred = let
252              fun exists' [] = false
253                | exists' ((_, x)::r) = pred x orelse exists' r
254              in
255                exists'
256              end
257        fun existsi pred = let
258              fun exists' [] = false
259                | exists' (arg::r) = pred arg orelse exists' r
260              in
261                exists'
262              end
263    
264      (* check the elements of a map with a predicate and return true if
265       * they all satisfy the predicate. Return false otherwise.  Elements
266       * are checked in key order.
267       *)
268        fun all pred = let
269              fun all' [] = false
270                | all' ((_, x)::r) = pred x andalso all' r
271              in
272                all'
273              end
274        fun alli pred = let
275              fun all' [] = false
276                | all' (arg::r) = pred arg andalso all' r
277              in
278                all'
279              end
280    
281    end (* IntListMap *)    end (* IntListMap *)
282    

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