• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1371
  • Last Modified:

Prolog - Systematically return last element in a list.

Im trying to figure out how to write a function to return the last element of a list in prolog.  I can drop elements off of a list, but without knowing the size how can I determine the last element?
0
Rowdyone52
Asked:
Rowdyone52
  • 2
1 Solution
 
Juan OcasioApplication DeveloperCommented:
How about reversing the list and then looking at the first element?

jocasio
0
 
Juan OcasioApplication DeveloperCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now