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 8368035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:17:45+00:00 2026-06-09T13:17:45+00:00

I am using read() to take in user input. I planned that my program

  • 0

I am using read() to take in user input. I planned that my program would accept input in the form of

a,b,c,d,e

and then I would convert that into a list of the elements. But doing a test in prolog i got this

26 ?- read(X).
|: abc,def,ghi,jkl.
X = (abc, def, ghi, jkl).

I am not sure, but is this returning a structure? What can I do to convert this into a list?

  • 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-06-09T13:17:46+00:00Added an answer on June 9, 2026 at 1:17 pm

    (abc, def, ghi, jkl) is a term with functor ‘,’ and arity 2. You can use term inspection predicates like (=..)/2, functor/3, arg/3 etc. to decompose it, or try write_canonical/1:

    ?- T = (abc, def, ghi, jkl), write_canonical(T).
    ','(abc,','(def,','(ghi,jkl)))
    T = (abc, def, ghi, jkl).
    

    To convert such tuples to lists, you can use a DCG:

    tuple_list((A,B)) --> !, tuple_list(A), tuple_list(B).
    tuple_list(A)     --> [A].
    

    Example:

    ?- T = (abc, def, ghi, jkl), phrase(tuple_list(T), Ls).
    T = (abc, def, ghi, jkl),
    Ls = [abc, def, ghi, jkl].
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Objective-C, how can I give/take the permissions for all user to read a
I am writing a simple shell program that must take input from a file
I'm using read/write locks on Linux and I've found that trying to upgrade a
I'm reading from the standard input using the read() system call but there's a
I have a config file that I read using the RawConfigParser in the standard
I wrote this procedure in a site. it take a string as input parameter(user
Using MIPS assembly if I prompt a user to input an integer how can
I want to take a .Net server variable and user that in the data
I am building a blackberry application takes input from user then send input to
I have a search form built in ASP.NET that has a dropdown list which

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.