Homework #4: Prolog Programming

Some hopefully helpful notes

The Actual Homework Problems:

  1. Write a function called "second", which has two params: a list and value. If the list has less than two elements, the value should be "-1". If the list has at least two elements, the value should be the second element of the list. These should be valid (true) queries:
        second([7],-1).
    second([7,3,9],3).
    
    second([1,2,3],A).
    should return that A =2.
    
  2. Write _either_ the oddL or evenL function which determines whether the length of a list is odd (or even).
    these should be valid queries:
    oddL([1,2],false).
    evenL([1,2,3,4],true).
    
    oddL([1,2,3],A).
    A = true.
    
  3. Write the sumList function which adds up the element values in a list.
    sumList([1,2,3],6).
    sumList([7,3,9],A).
     A = 19.