'how to use apply map in Racket

im writing a function in racket that consumes a list of lists (where the type of the elements in the inner list may be any type). The function returns a list of lists – such that for each inner list lst (in the original list) the following is done – 1. If lst contains at least one number, then lst is replaced with a list of size two, containing the minimum and maximum in lst, and 2. Otherwise, lst is replaced with a null.

take into consideration that i have this function that works fine, this function takes list of any and return a list of numbers that the list contain e.x if i give it '( 1 'f 7 'a ) it return '( 1 7)

(: sublist-numbers : (Listof Any) -> (Listof Any))

so i start write my function and wanted to use this function above here is my code:

(: min&max-lists : (Listof Any) -> (Listof Any))

(define (min&max-lists lst)
(apply append (map (lambda (slst)
                     (if (null? slst)
                         '()
                         ((>= (length (sublist-numbers slst)) 1) '(1))
                         )
              )
            lst)) 
  )

but for now i wanted to check if at-least i can iterate over each list in the lists but i get an exception

Type Checker: type mismatch expected: (Listof Any) given: Any in: slst . Type Checker: Cannot apply expression of type Boolean, since it is not a function type in: ((>= (length (sublist-numbers slst)) 1) (quote (1))) . Type Checker: Summary: 2 errors encountered in: slst ((>= (length (sublist-numbers slst)) 1) (quote (1)))

if anyone can help me to solve this problem.

here is an example to a test to this function:

(test (min&max-lists '((any "Benny" 10 OP 8) (any "Benny" OP (23)))) => '((8 10) ()))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source