| Did you know ... | Search Documentation: |
| Pack onepointfour_basics -- prolog/doc/README_stringy_and_charylist_type.md |
stringy_and_charylist_type.plSimple analysis for stringy and chary terms.
stringy_and_charylist_type.plt](../stringy_and_charylist_type.plt) (0BSD license)
We introduce the following additional vocabulary:Please refer to the README.md file.
stringy_type_with_length(Stringy,Type,Throw)?- charylist_type(_,T). T = var. ?- charylist_type([],T). T = empty. ?- charylist_type([h,e,l,l,o],T). T = chars(5). ?- charylist_type([0'h,0'e,0'l,0'l,0'o],T). T = codes(5). ?- charylist_type(foo,T). false. ?- charylist_type([x],foo). false.
?- stringy_type(foo,T).
T = atom.
?- stringy_type("foo",T).
T = string.
?- stringy_type(_,T).
T = var.
?- stringy_type([h,e,l,l,o],T).
false.
?- stringy_type([h,e,l,l,o],T,throw).
ERROR: check failed : type error (the culprit is not of the required type)
ERROR: message : the value should fulfill 'stringy-ness'
ERROR: culprit : [h,e,l,l,o]
?- stringy_type_with_length("foo",T).
T = string(3).
?- stringy_type_with_length("",T).
T = string(0).
?- stringy_type_with_length('',T).
T = atom(0).
?- stringy_type_with_length(_,T).
T = var.
?- stringy_length("foo",T).
T = 3.
?- stringy_length(foo,T).
T = 3.
?- stringy_length(X,3).
ERROR: check failed : instantiation error (the culprit is not instantiated (enough))
ERROR: message : the value should fulfill 'nonvar-ness'