This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/library/lineutils.yap
vsc 817663588d get rid of debugging messages
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2057 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2008-01-23 22:22:42 +00:00

42 lines
743 B
Prolog

:- module(line_utils,
[search_for/3,
scan_natural/3,
scan_integer/3,
split/3
]).
:- use_module(library(lists),
[member/2]).
search_for(C) --> [C], !.
search_for(C) --> [_],
search_for(C).
scan_integer(N) -->
"-", !,
scan_natural(0, N0),
N is -N0.
scan_integer(N) -->
scan_natural(0, N).
scan_natural(N0,N) -->
[C],
{C >= 0'0, C =< 0'9 }, !,
{ N1 is N0*10+(C-0'0) },
get_natural(N1,N).
scan_natural(N,N) --> [].
split(String, SplitCodes, [S|Strings]) :-
split(SplitCodes, S, Strings, String, []).
split(SplitCodes, [], [New|Set]) -->
[C],
{ member(C, SplitCodes) }, !,
split(SplitCodes, New, Set).
split(SplitCodes, [C|New], Set) -->
[C], !,
split(SplitCodes, New, Set).
split(_, [], []) --> [].