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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:39:18+00:00 2026-06-12T15:39:18+00:00

I am trying to write a program to determine if a sentence is a

  • 0

I am trying to write a program to determine if a sentence is a palindrome. This is what I have so far:

palindrome :- write('Sentence: '),
    read(Word),
    name(Word,List),
    palCheck(List).

palCheck(List) :- reverse(List,List).

reverse(L1,L2) :- rev(L1,[],L2).
rev([],L,L).
rev([H|L],L2,L3) :- rev(L,[H|L2],L3).

The problem I have is when I get to a space or an uppercase letter. What I ultimately want is to be able to write DoD dod and get it to pass. I have tried using downcase_atom(X,Y), but having trouble using it as the sentence is something other than an atom.

  • 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-12T15:39:19+00:00Added an answer on June 12, 2026 at 3:39 pm

    read/1 acts in a peculiar way: it’s a very powerful primitive, able to fully parse Prolog syntax. But the space make the input ill formed. Then surround the literal with quotes, or use some other input primitive: see your Prolog manual!

    ?- palindrome('DoD DoD').
    

    In SWI-Prolog, this query does the check:

    ?- current_stream(_,read,S), read_line_to_codes(S,Cs), maplist(to_lower,Cs,Ls), reverse(Ls,Ls).
    |: AbcCBA
    S = <stream>(0x7fae7b1088e0),
    Cs = [65, 98, 99, 67, 66, 65],
    Ls = [97, 98, 99, 99, 98, 97] .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a program that will read from a flat file of
I'm trying write a program that takes a list of names, sorts those names,
I'm trying to write a shell program that, given an unsorted list of numbers
I'm trying to write a program that would convert celcius to fahrenheit and visa-versa.
I am trying to write a program that will prompt you to enter someone's
I am trying to write a program that sends basic text files from one
I'm trying to write a program in Control Language which creates and populates a
I am trying to write a program that allows a binary to be run,
I'm trying to write a program in Python and I'm told to run an
I am trying to write a program that displays the integers between 1 and

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.