Question

Please Provide me all Necessary Screenshot with copy able code. Thanks Write a scheme function named...

Please Provide me all Necessary Screenshot with copy able code. Thanks

Write a scheme function named up-to-first-number that takes a list as its input and returns a list containing all the elements up to the first numeric element in the input list. You can use the number? predicate function to determine whether an element is a number or not.

Sample runs:

(up-to-first-number '(a b c d 1 2 3 )) returns (a b c d)

(up-to-first-number '(d e f 7)) returns (d e f)

(up-to-first-number '(g h i)) returns (g h i)

(up-to-first-number '(1 2 3)) returns NIL

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The simple scheme function is described below for obtaining the required output

(define (up-to-first-number lst)
  (if (or <list[]=null>   ; if either the list is empty
          <list[0] = no. >)  ; or the first element is a number
      <list= Null>       ; then return the empty list
      (cons <Print the first element> ; otherwise cons the first element
            (up-to-first-number <list[length]>)))) ; and advance the recursion till the number is detected.

If your interpreter implements pre existing procedure takef , we can write the scheme function as follows :-

This will obtain the same output as required .

(define (up-to-first-number lst)
  (takef lst (negate number?)))
Add a comment
Know the answer?
Add Answer to:
Please Provide me all Necessary Screenshot with copy able code. Thanks Write a scheme function named...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

  • Please give me the R code for the following questions. Create a variable named x1 which...

    Please give me the R code for the following questions. Create a variable named x1 which contains five equally spaced numbers. You may NOT use the c() function to do this. Find the mean of all elements of x1 except the second. Create a list My.List where the first list element is a two-column data frame containing x1 and the vector [2, 1, 4, 7, 8], and the second list element is the logical vector [T, F, NA, T, F]....

  • You must write each of the following scheme functions. You must use only basic scheme functions...

    You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. This problem need to use DrRacket software. Racket Language. Write a function named (first-n L1 N) that returns the first N elements of L1. If N is negative, return the empty list. If N exceeds the length of L1 return all elements of L1. (first-n...

  • Lisp program count-of (symbol list): Write a function named count-of that takes two parameters, a symbol...

    Lisp program count-of (symbol list): Write a function named count-of that takes two parameters, a symbol and a list. Count the number of instances of x in the list. Do not count the number of x in any sub-lists within the list. Test: count-of 'a '(a 'a(a c) d c a). Result: 2 trim-to (symbol list): Write a function named trim-to that takes a symbol and list as parameters. Return a new list starting from the first occurrence of the...

  • Please place all of the following functions (defun …) into a SINGLE .lsp file As such,...

    Please place all of the following functions (defun …) into a SINGLE .lsp file As such, be sure to use the EXACT SAME function names and parameter numbers and orders I provide ​ Write a function ONEFIB that takes a single parameter n and returns the nth Fibonacci number. Write a function ALLFIB that takes a single parameter n and returns a list of the first n Fibonacci numbers. Do not worry about efficiency here. HINT: You can use ONEFIB...

  • Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with...

    Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with output plesase. LISP Programming Assignment It is a good idea to start this assignment early; Lisp programming, while not inherently difficult, often seem somewhat foreign at first, particularly when it comes to recursion and list manipulation. This assignment is loosely based on material by Dr. Henri Casanova.   Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem...

  • Must use the Scheme language to solve the problem. Thanks! Write a function deep-mult which takes...

    Must use the Scheme language to solve the problem. Thanks! Write a function deep-mult which takes a list as a parameter and computes the product of all numbers which appear anywhere in the list or in sublists. We will follow the usual mathematical convention that a product of no numbers is 1 (the multiplicative identity). You may find it useful to know that Scheme has a function number? which returns #t if its argument is numeric atom and #f otherwise....

  • NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT...

    NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT WOULD CAUSE THE HW1.java TO PRINT THE RIGHT DATA.!!! The LinkedList class implements both the List interface and the Stack interface, but several methods (listed below) are missing bodies. Write the code so it works correctly. You should submit one file, LinkedList.java. Do not change the interfaces. Do not change the public method headers. Do not rename the LinkedList class. None of your methods...

  • Plz help me with the code. And here are the requirement. Thanks!! You are required to...

    Plz help me with the code. And here are the requirement. Thanks!! You are required to design and implement a circular list using provided class and interface. Please filling the blank in CircularList.java. This circular list has a tail node which points to the end of the list and a number indicating how many elements in the list. And fill out the blank of the code below. public class CircularList<T> implements ListInterface<T> { protected CLNode<T> tail; // tail node that...

  • Please write the code using matlab 1) i. Create an anonymous function named optimist, that accepts...

    Please write the code using matlab 1) i. Create an anonymous function named optimist, that accepts a single variable as input i Create a row vector Tthat represents the number of seconds in two minutes, starting ii. Call the function optimist on the vector T, store the result in variable R1 and returns the double of that variable from one and ending at a hundred and twenty v. Create an anonymous function named pessimist, that accepts a single variable as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT