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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:57:04+00:00 2026-05-26T09:57:04+00:00

I am having trouble figuring out how to access a single character from a

  • 0

I am having trouble figuring out how to access a single character from a list of strings without using recursion, but instead backtracking.

For example I have this list of Strings and I want to be able to return a single character from one of these strings (‘.’ ‘o’, ‘*’). The program I am working on is treating it as rows and columns. It is a fact in my database that looks like this:

matrix(["...o....",
        ".******.",
        "...o....",
        ".*...*..",
        "..o..*..",
        ".....*..",
        ".o...*..",
        "....o..o"].

I have the predicate:

get(Row,Col,TheChar) :- 

that takes a row and column number (with index starting at 1) and returns the entry (TheEntry) at that specific row and column.

I have a feeling my predicate head might not be build correctly but I’m really more focused on just how to go through each String in the list character by character without recursion and returning that.

I am new to prolog and am having major difficulty with this.

Any help at all would be greatly appreciated!

Thank you!

  • 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-26T09:57:04+00:00Added an answer on May 26, 2026 at 9:57 am

    An implementation of get/3 might look like this:

    get(Row,Col,TheChar) :-    
       matrix(M),
       nth(Row,M,RowList),
       nth(Col,RowList,TheChar).
    

    Note that TheChar is unified to a character code e.g.

    | ?- get(1,4,X).
    X = 111
    

    If you want to get see the character you can for instance use atom codes, e.g.

    | ?- get(4,2,X), atom_codes(CharAtom,[X]).
    X = 42
    CharAtom = *
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble figuring out how to access a cookie from a compiled object.
I have been having a lot of trouble figuring out how I can access
I'm having trouble figuring out how to exclude /public/bin from this rewrite rule RewriteCond
I'm just getting into using prototypal JavaScript and I'm having trouble figuring out how
I'm having trouble figuring out how to prevent people from editing the amount in
I am having trouble figuring out how to get Facebook insights into from my
This seems like a straightforward task, but I'm having trouble figuring out the rails
I'm having trouble figuring out how to call a method from a parent module
I'm having trouble figuring out how to pass strings back through the parameters of
Having trouble figuring out how to put a single quote in my view. <td><%=

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.