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

Diff of /smlnj-lib/branches/rt-transition/Util/int-binary-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-binary-map.sml  (* int-binary-map.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 427  Line 430 
430              foldli g empty m              foldli g empty m
431            end            end
432    
433      (* check the elements of a map with a predicate and return true if
434       * any element satisfies the predicate. Return false otherwise.
435       * Elements are checked in key order.
436       *)
437        fun exists pred = let
438              fun exists' E = false
439                | exists' (T{value, left, right, ...}) =
440                    exists' left orelse pred value orelse exists' right
441              in
442                exists'
443              end
444        fun existsi pred = let
445              fun exists' E = false
446                | exists' (T{key, value, left, right, ...}) =
447                    exists' left orelse pred(key, value) orelse exists' right
448              in
449                exists'
450              end
451    
452      (* check the elements of a map with a predicate and return true if
453       * they all satisfy the predicate. Return false otherwise.  Elements
454       * are checked in key order.
455       *)
456        fun all pred = let
457              fun all' E = true
458                | all' (T{value, left, right, ...}) =
459                    all' left andalso pred value andalso all' right
460              in
461                all'
462              end
463        fun alli pred = let
464              fun all' E = true
465                | all' (T{key, value, left, right, ...}) =
466                    all' left andalso pred(key, value) andalso all' right
467              in
468                all'
469              end
470    
471    end    end

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