[mercury-users] string__first_char

Ralph Becket rbeck at microsoft.com
Mon Oct 16 18:31:29 AEDT 2000


>From Michael Day on 16/10/2000 04:17:28
> 
> Well, first_char is useful when processing strings in a streamy kind of
> way; in particular I've written a bunch of regular expression code which
> uses first_char all over the place, where foldl is not really appropriate.

Why not adapt Fergus' suggestion with something like:

:- type streeng == {string, int}.	% {String, IndexIntoString}

:- pred read_next_char(char::in, streeng::in, streeng::out) is det.

read_next_char(C, {S, I}, {S, I + 1}) :-
	C = string__unsafe_index(S, I).

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list