Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:46:03+00:00 2026-05-27T01:46:03+00:00

I need to read any line (from user_input) into an atomic list, e.g.: Example

  • 0

I need to read any line (from user_input) into an atomic list, e.g.:

Example line, which contains any ASCII chars.

into:

[Example,'line,',which,contains,any,ASCII,'chars.']

what I’ve got so far:

read_line_to_codes(user_input, Input),
atom_codes(IA,Input),
atomic_list_concat(AlistI,' ',IA).

but that only works w/ single words, because of atom_codes.
read/2 also complains about spaces, so is there any way to do this?

oh and maybe then splitting at comma into 2d-lists, appending the dot/exclamationmark/questionmark, e.g.:

[[Example,line],[which,contains,any,ASCII,chars],'.']

btw: that’s SWI-prolog.

EDIT: found the solution:

read_line_to_codes(user_input, Input),
string_to_atom(Input,IA),
atomic_list_concat(AlistI,' ',IA),

can’t answer my own question because i don’t have 100 reputation :-/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:46:03+00:00Added an answer on May 27, 2026 at 1:46 am
    input_to_atom_list(L) :-
        read_line_to_codes(user_input, Input),
        string_to_atom(Input,IA),
        tail_not_mark(IA, R, T),
        atomic_list_concat(XL, ',', R),
        maplist(split_atom(' '), XL, S),
        append(S, [T], L).
    
    is_period(.).
    is_period(?).
    is_period(!).
    
    split_atom(S, A, L) :- atomic_list_concat(XL, S, A), delete(XL, '', L).
    
    %if tale is ? or ! or . then remove
    %A:Atom, R:Removed, T:special mark
    tail_not_mark(A, R, T) :- atom_concat(R, T, A), is_period(T),!. 
    tail_not_mark(A, R, '') :- A = R.
    

    DEMO

    1 ?- input_to_atom_list(L).
    |: Example line, which contains any ASCII chars.
    L = [['Example', line], [which, contains, any, 'ASCII', chars], '.'].
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a solution to read raw binary from any filetype stored on a
I need to read from a variety of different text files (I've some delimited
I need to read selected files, matching on the file name, from a remote
I need to read account number from Maestro/Mastercard with smart card reader. I am
I need to read data added to the end of an executable from within
I need to read the value of a property from a file in an
I need to read the user's fingerprint from my application. What I really want
I need to read in an Intel Hex file which looks something like this:
I need to write a simple terminal-based program that should, Read some text from
I'm writing a little class to read a list of key value pairs from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.