• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1358
  • 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 OcasioCommented:
How about reversing the list and then looking at the first element?

jocasio
0
 
Juan OcasioCommented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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