Develop a new predict function

Assignment Help Programming Languages
Reference no: EM131296983

Question#1:

a) Using built in predict function NUMBERP, develop a new predict function so-called "elemnts_are_numbers" that checks all the elements of a list are numbers.

See these examples:
> (elemnts_are_numbers '( 1 8 9 6) )
T
> (elemnts_are_numbers ‘( a 8 9 b ) )
NIL

b) Test your function on your computer by some (at least 3 examples) of different values for its input list and show results of your examples for this function.

Question#2:

In this exercise assume: "first= car" and "rest = cdr" and L is a given list containing only numbers

a) Analyze this code and explain what myfunction5 is doing? (defun myfunction4 (n L)
(cond
((null L) nil)
((zerop n) (first L))
(t (myfunction4 (- n 1) (rest L)))))
b) Test this function on your computer by some (at least 3 examples) examples of different values for its parameters (n L) and show your results of your examples for this function.

Question#3:

a) Assume L is list of only integer numbers (Including zeros, or positive, or negative numbers, or could be an empty list), write a function that finds and returns the leftmost even number from this (if any, otherwise return NIL).

Example: for L= (-7, 17, 8, 9, -16, 19, 0, 27, 28, 13) , you should return: 28

b) Test your function on your computer by some (at least 3) examples of different values for its input parameter (L) and show your code and results of your examples for this function.

Question#4:

a) Compare these two functions (sum-list 1 and sum-list2), what these function do?

b) which one is more efficient or more readable? and why?
(defun sum-listl (L)
(if (null L) 0
(+ (first L)
(sum-list (rest L)))))
(defun sum-list2 (L)
(apply #'+ L))

Reference no: EM131296983

Questions Cloud

Analyze potential barriers to feasibility of implementing : What are the unique or parallels between the implementation of this solution and the literature? Analyze potential barriers to the feasibility of implementing the proposed solution.
What did having a key informant add to your understanding : What understanding was gained from participation compared to just observing?What did having a key informant add to your understanding?What was learned from participant observation at this event that a questionnaire or interview about it might miss?
What is an advantage for sue of starting her own health club : How will CHC be taxed, given that Sue plans to be the sole owner?- What is an advantage for Sue of starting her own health club instead of operating a franchise health club?
Union and nonunion entities : Aware of the union and nonunion entities within Elora Jean & Co., you have observed that the production supervisors are unclear on the facility's union grievance procedures, and the nonproduction supervisors are unclear on how to handle employee c..
Develop a new predict function : Develop a new predict function so-called "elemnts_are_numbers" that checks all the elements of a list are numbers - Compare these two functions (sum-list 1 and sum-list2), what these function do?
Analyze any two types of qualitative research methods : Analyze and describe any two types of qualitative research methods. Explain the advantages and disadvantages of qualitative as well as quantitative research.
Small business that develops gaming software : A few years ago, a friend of yours started a small business that develops gaming software. The company is doing well, and is valued at $1.5 million based on multiples for comparable public companies, after adjustments for their lack of marketabili..
Is your firm involved in franchising : A health club differs from manufacturing firms in that it produces a service rather than products.- Why might Sue need other partners if she had established a manufacturing firm instead of a health club?
Approached by friend who is starting minor league baseball : You have been approached by a friend who is starting a minor league baseball team in your city. He is seeking ten investors to put up $50,000 each. Expected net cash inflows over each of the next ten years are $350,000.

Reviews

len1296983

12/1/2016 5:32:07 AM

For answering the next questions: install Common LISP interpreter on your computer, and save the code of these functions in a "*.lisp" file (giving them proper names) using a text editor and run your lisp file on your computer (for example load "question5.lisp"). For each question, also print the source code of your file "*.lisp" inside your report and its corresponding results.

Write a Review

Programming Languages Questions & Answers

  Create a template that changes the value of 2 variables

Use the template in a program where you change the value of 2 variables of type int and 2 variables of type long.

  What advantages do css have when creating web pages

Explain which structure you prefer and why. Locate two Web sites that utilize this structure, and list their URLs.

  Create while-end repetition structure includes a nested if

Create your own While-End (or For-End) repetition structure that includes a nested if-then selection structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example.

  Explaining valid advice for naming variables

Which of the following is valid advice for naming variables? To save typing, make most variable names one or two letters.

  Deisgn class contains data fields for height and surfacearea

Deisgn a class named Rectangle that contains data fields for height width and surfaceArea and a method named computeSurfaceArea?

  Determine if a word is a palindrome

Determine if a word is a palindrome. Using a doubly link list read in a word character by character Store each character in its own node. Keep a counter of the number of characters that make up the word.

  C program that prompts the user to enter some information

Write a C program that prompts the user to enter some information about up to ten individuals. It should store this information in a structure. The program should obtain the information from the structure, and output it as shown in sample run belo..

  Debug a simple visual basic program

The GUI program will have a button that creates a new window with the word Hello. Enhance the display by making the word change color, move, or change to another language (such as Hola).

  Demonstrate that you can read and understand code

What will the code output when run - What are individualScores, bonusScore, baseScore, and teamScore? What do you think the difference is between the keywords let and var?

  Find the sum and difference for numbers

Write a program that prompts the user for two numbers, finds the sum and difference for those numbers and displays a descriptive label for each computation by calling two different functions. Use Function Prototypes.

  Prepare a function that generates a polynomial

Write a function genPoly(n) that generates a polynomial of length n (degree n-1), all of whose coefficients are 1.0.

  Design and draw a ladder diagram circuit

Design and draw a ladder diagram circuit suitable for a PLC which will fulfil the following control requirement and explain briefly the technique of multiplexed switching of analogue signals

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd