Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Artificial Intelligence Practice with Scheme 1. Write a function in Scheme to re

ID: 3867158 • Letter: A

Question

Artificial Intelligence

Practice with Scheme

1. Write a function in Scheme to return –1, 0, +1 depending on two parameters a and b:

a < b return –1

a > b return +1

a = b return 0

2. Write a recursive function in Scheme, called “get-element” which takes two parameters, an index and a list. The function returns the element at the given index position in the list or #f if element is not contained. Indices start at 1 and go to the length of the list.

3. Question: How would you change the function so it returns the whole list if the element is not contained?

Explanation / Answer

I have writing a code in python

def dependencyFun(a,b):
if a<b:
return -1
elif a>b:
return 1
elif a==b:
return 0
x=dependencyFun(4,5)
print (x)
OUTPUT: -1

2
def get_element(index,list):
length=len(list)
if(index<=length-1):
return list[index-1]
else:
return '#f'
list=[1,2,3,4,5,6]
y=get_element(3,list)
print (y)
OUTPUT : 3
3:
def get_elementOrList(index,list):
length=len(list)
if(index<=length-1):
return list[index-1]
else:
return list
list=[1,2,3,4,5,6]
z=get_element(6,list)
print (z)
OUTPUT: 6

If you want some other language please mention ,

which language you want

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote