All pastes #238414 Raw Edit

Untitled

public text v1 · immutable
·published 2006-11-04 23:46 UTC
rendered paste body
(* rm s
 TYPE: string -> string
 PRE : (none)
 POST: s med alla dubletter bortplockade
*)
fun rm "" = ""
  | rm s =  
    let
	(* rm' s c
	 TYPE: string -> char -> string
	 PRE : (none)
	 POST: s med alla förekomster av c bortplockade
	*)
	fun rm' "" c = ""
	  | rm' s c =
	    let
		val firstChar = String.sub(s,0)
		val theRest = String.substring(s,1,size(s)-1)
	    in
		if firstChar=c then
		    (rm' theRest c)
		else
		    Char.toString(firstChar)^(rm' theRest c)
	    end    
	val firstChar = String.sub(s,0)
    in
	Char.toString(firstChar)^rm (rm' s firstChar)
    end;