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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:28:42+00:00 2026-06-14T20:28:42+00:00

Doing a small example, I want to insert a symbol within a list at

  • 0

Doing a small example, I want to insert a symbol within a list at a certain pozition

domains
    element = symbol
    list = element*
    position = integer
predicates
    insert (element, position, list, list) %(input,input,input,output)
clauses 
    insert (E,_,[],[E]). 
    insert (E, 1,[H|T],[E|[H|T]]).       %(I insert E on the "first" position)
    % I get errors how E and T are not bound. I have no idea how to make them bound
    insert (E,P,[H|T],[H1|T1]) :-
           P > 1,
           P1 = P - 1,
           insert (E,P1,T,T1).

It doesn’t work … but I don’t know why. Well it kinda works. I would like it to show me outputList = [NEW_LIST] instead of showing every symbolName=_ and then outputList = [_,_,_,_].

  • 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-14T20:28:44+00:00Added an answer on June 14, 2026 at 8:28 pm

    Apparently there is some problem with symbol data type, if I use integer, it fixes itself.

    Also, this is esential:

    domains
        element = integer
         list = element*
         position = integer
    predicates
         insert (element, position, list, list) %(input,input,input,output)
    clauses 
         insert (E,_,[],[E]). 
         insert (E, 1,[H|T],[E|[H|T]]).
         insert (E,P,[H|T],[H|T1]) :-  % has to be "H" (or anything else) in both
              P > 1,                   % so prolog understands what we are trying to do
              P1 = P - 1,              % don't really understand why though
              insert (E,P1,T,T1).      % I might be wrong
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want let the user choose what style my application has.Small example would be
I sometimes want to make small edits to small file from within the shell
I am trying to make a small thread example. I want to have a
I am doing an contact list android application but i have a small problem
I am doing an contact list android application but i have a small problem
I am doing small Silverlight app which will allow users to Create orders. I
While doing some small regex task I came upon this problem. I have a
I'm doing a small app in Excel, and I have the following code when
I'm doing jquery small animation of fade in to form validation This is working
i am doing one small application , wheich have login functionality, in the user

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.