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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:25:06+00:00 2026-06-10T11:25:06+00:00

I’m trying to implement a Scheme-like map function, i.e. map([X1, X2, ..], Fun) ->[Fun(X1),

  • 0

I’m trying to implement a Scheme-like map function, i.e.

map([X1, X2, ..], Fun) ->[Fun(X1), Fun(X2), ...] 

I wrote this code:

map([], Fun, []).
map([H|T], Fun, [HO|TO]) :- call(Fun, H, HO), map(T,F,TO).

Now, looking at this run:

?- map([1,2,3], plus(1), X).
X = [2, 3, 4] ;
X = [2, 3, 4] ;
X = [2, 3, 4] ;
X = [2, 3, 4] ;
ERROR: map/3: Arguments are not sufficiently instantiated
   Exception: (9) map([3], _G380, _G351) ?
  1. How can I make it stop after the first solution provided?
  2. How can I trace it?If i use trace it stop the execution after the first solution.
  • 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-10T11:25:07+00:00Added an answer on June 10, 2026 at 11:25 am

    1) the code you posted has a problem: map(T,F,T0) should be map(T,Fun,T0). without this change i get the error you mentioned immediately; with this correction it runs flawlessly. (it is also a good idea to change map([], Fun, []) to map([],_Fun,[]) since you dont use the variable Fun – you should get a warning for singleton variables)

    2) when you trace it and reach the first solution, press ;. alternatively, in swi-prolog, press the spacebar instead of enter and the tracing will continue.

    6 ?- trace.
    true.
    
    [trace] 6 ?- X = 1 ; X = 2.
       Call: (7) _G522=1 ? creep
       Exit: (7) 1=1 ? creep
    X = 1 ;
       Call: (7) _G522=2 ? creep
       Exit: (7) 2=2 ? creep
    X = 2.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is

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.