Prolog Combining Two Lists


I am new to prolog and would appreciate any help on the following question:

I need to write a program that accepts two lists and appends the second to first and displays this new list and its length. I know that prolog might have some built in functions to make this all easier...but I do not want to use those.

eg: newlist([a,b,c],[d,e,f],L3,Le). would return L3=[a,b,c,d,e,f] and Le=6

Here is what I have so far:

newlist([],List,List,0) newlist([Element|List1],List2,[Element|List3],L) :- newlist(List1,List2,List3, LT), L is LT + 1.

This does the appending correctly but I can only get the length of the first list instead of the combined list. Is there a way for me to add the second list's length to the first to get the combined list length?

Thanks, and sorry if this question is rather easy...I am new.



Is there a way for me to add the second list's length to the first to get the combined list length?


You should replace:





  • How to add flexible delta columns using dplyr?
  • Prolog - Cartesian product calculator
  • Different slicing behaviors on left/right hand side of assignment operator
  • AbstractTableModel contains proper data but will not update on fireTablDataChanged
  • How to do lappend in a while loop using regexp
  • Print bullet before each sentence + new line after each sentence SQL
  • Merge Multiple Lists of Lists Based on Template
  • Dynamically create button using Tkinter
  • Exception handling as per java coding standards
  • Whats the right place for testhelper-classes? (phpunit/best practise)
  • SQL query to group by maximal sets of a column having inner consecutive distances below a threshold
  • Microsoft Excel Pivot miscalculation in Sum for positive and negative numbers
  • jquery validation - waiting for remote check to complete
  • CSS - Cannot get one spanned style to override another inherited style and align left
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • Suppressing passwd when calling sqlplus from shell script
  • Calling Worksheet functions from vba in foreign language versions of Excel
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Email format validation in mvc3 view
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Why is the size of this struct 32?
  • How to add date and time under each post in guestbook in google app engine
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Why winpcap requires both .lib and .dll to run?
  • Arrays break string types in Julia
  • retrieve vertices with no linked edge in arangodb
  • Proper folder structure for lots of source files
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Turn off referential integrity in Derby? is it possible?
  • apache spark aggregate function using min value
  • Add sale price programmatically to product variations
  • Unable to use reactive element in my shiny app
  • Net Present Value in Excel for Grouped Recurring CF
  • How do I use LINQ to get all the Items that have a particular SubItem?