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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3717 - (download) (annotate)
Sat Apr 2 17:41:27 2016 UTC (5 years ago) by jhr
File size: 506 byte(s)
  More work on MLton support
(* list.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

signature LIST_EXT =
  sig

    include LIST

    val mapi : (int * 'a -> 'b) -> 'a list -> 'b list

  end

structure ListExt : LIST_EXT =
  struct

    open List

    fun mapi f xs = let
	  fun mapf ([], _, ys) = List.rev ys
	    | mapf (x::xs, i, ys) = mapf (xs, i+1, f(i, x)::ys)
	  in
	    mapf (xs, 0, [])
	  end

  end

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