As part of my assignment i have been given the task to:
Write a function that takes two lists as input, a list L1 containing characters and a list L2
containing numbers. For each of the number n contained in L2, the function will display the first
n character of the list L1. For example:
L1 '("h" "e" "l" "l" "o" "w" "o" "r" "l" "d")
L2 '(2 3 1 5 10)
Output:
h e
h e l
h
h e l l o
h e l l o w o r l d.
i know the function takes two arguments but i don't know how to apply the second the list which is like a selector,it reads each number in the second list and extracts the character in that position in the first list.
( define two-sequences
( lambda ( l1 l2 )
(for/list ([ i l1 ] [ j l2 ])
which function should i use to do this.
You need to print the first n elements of a list. Here's how you do that:
To print the first
nelements of a list,lst:nis zero print a newline;nis 1 print the first element oflstand a newline;nis more than 1 print the first element of thelst, a space, and then printn - 1elements of the rest oflst(hint: you can use a function you are currently writing to do this);nis anything else then this is an error.Write this as a proceducre: call it
print-nfor instance. Then the procedure which answers the question is:And