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/binary-map-fn.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/binary-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  (* binary-map-fn.sml  (* binary-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) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.   * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.
7   *   *
8   * This code was adapted from Stephen Adams' binary tree implementation   * This code was adapted from Stephen Adams' binary tree implementation
# Line 443  Line 446 
446              foldli g empty m              foldli g empty m
447            end            end
448    
449      (* check the elements of a map with a predicate and return true if
450       * any element satisfies the predicate. Return false otherwise.
451       * Elements are checked in key order.
452       *)
453        fun exists pred = let
454              fun exists' E = false
455                | exists' (T{value, left, right, ...}) =
456                    exists' left orelse pred value orelse exists' right
457              in
458                exists'
459              end
460        fun existsi pred = let
461              fun exists' E = false
462                | exists' (T{key, value, left, right, ...}) =
463                    exists' left orelse pred(key, value) orelse exists' right
464              in
465                exists'
466              end
467    
468      (* check the elements of a map with a predicate and return true if
469       * they all satisfy the predicate. Return false otherwise.  Elements
470       * are checked in key order.
471       *)
472        fun all pred = let
473              fun all' E = true
474                | all' (T{value, left, right, ...}) =
475                    all' left andalso pred value andalso all' right
476              in
477                all'
478              end
479        fun alli pred = let
480              fun all' E = true
481                | all' (T{key, value, left, right, ...}) =
482                    all' left andalso pred(key, value) andalso all' right
483              in
484                all'
485              end
486    
487    end (* functor BinaryMapFn *)    end (* functor BinaryMapFn *)

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