Is there any way in which I can convert a string to list separated by spaces.The string has to be entered by the user.
Suppose How are you today ?
is the string entered by the user,I want to store it in a list say L,
L=['How','are','you','today','?']
. How can I do this??
Converting a user input string to list
1.1k Views Asked by AudioBubble At
2
There are 2 best solutions below
0

SWI-Prolog offers tokenize_atom
?- [library(porter_stem)].
?- tokenize_atom('How are you today ?', L).
L = ['How', are, you, today, ?].
note that quoting atoms is necessary only when the lexical representation aliases some other type (notably variables)
?- split_string("How are you today ?", " ", "", L).
per this site.