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

Using Scheme: Write a function that organizes an input list as a list of lists o

ID: 3734374 • Letter: U

Question

Using Scheme:

Write a function that organizes an input list as a list of lists or a list of pairs where repeated elements are only added once and instead a count is maintained, i.e., each element of the original list is the first element in a sub-list (or in a pair) with the count as the second element in the sub-list (or in the pair a) Create the predicate duplicatePair which evaluates to a list-of-pairs. Examples (duplicatePair '(1 a 5 62ba55)) ((1 . 1) (a . 2) (5 . 3) (6 . 1) (2.1) (b.1)) (duplicatePair '(b a a a))

Explanation / Answer

A) Implementation to create the predicate duplicatePair evaluating the list-of-pairs.

> (list 1 2 3 2 4)
> for val in list:
> (append (cons (list[val] list.count(val[i]) == val[i]))))

B) Implementation to create the predicate DuplicateListPair evaluating the list-of-lists.

> (list 1 2 3 2 4)
> for val in list:
> mylist = (append(list(list[val] list.count(val[i]) == val[i]))))
> (list mylist)


C) Implementation to create the predicate DuplicatedSorted list evaluating the list-of-list with decreasing count.
> (list 1 2 3 2 4)
> for val in list:
> mylist = (append(list(list[val] list.count(val[i]) == val[i]))))
> (list sort(mylist)<)

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