Stack Exchange
Find minimum pairwise product in two lists
I need to write a function that performs the following: Given [ 2 6 3 ] and [ 4 6 2 ], their products are [ (2 * 4) (6 * 6) (3 * 2) ], or [ 8 36 6 ],
so the smallest product is 6.
I have a helper function to get the smallest integer in each list:
(define ( myListMax Lst )
( if ( null? Lst )
0
( if ( null? ( cdr Lst ) )
( car Lst )
( if ( > ( car Lst ) ( myListMax ( cdr Lst ) ) )
( car Lst )
( myListMax ( cdr Lst ) )
)
)
)
)

I have the following function that calls the helper function to help me achieve the objective. Here is the function:
(define (smallProd LstOne LstTwo)

(* 
(myListLeast(LstOne) (myListLeast(LstTwo)
))))

But when I run my code I get the following message:

(smallProd '(1 2 3) '(4 5 6))

; application: not a procedure;
;  expected a procedure that can be applied to arguments
;   given: '(1 2 3)
; [,bt for context]


I would appreciate some help.

Parentheses have meaning in lisps, and you can't add them wherever you like. I'm not really sure what this is supposed to be, but it certainly won't do anything good: (myListLeast(LstOne) (myListLeast(LstTwo)). This is the reason for the error you report: (LstOne) --> ((1 2 3)) is trying to call the list (1 2 3) as a procedure.

Tip #1: please look at other Scheme or Racket code and pay attention to how it is formatted, then emulate that. Especially, do not scatter parentheses all over the place. Tip #2: your approach to the problem will not work. It would work for your over-simplified test data of (1 2 3) and (4 5 6), but it would not work for (2 6 3) and (4 6 2); your approach yields 4, but (as you have already noted) the answer is 6.

Use the approach that the example takes – first multiply the list elements to get another list, then take the smallest element. (You could also find the minimum "on the fly".)

Please choose a non-generic title that can be searched by people with the same problem.  "Scheme Programming Function Assistance" could mean pretty much anything. "Find minimum pairwise product in two lists" is specific, meaningful and searchable. See also: Why is “Can someone help me?” not an actual question?

Your code (with fixed formatting) makes the assumption that the two smallest numbers would be in the same position -
(define (smallProd LstOne LstTwo)
  (* (myListLeast LstOne)      ; fixed parens
     (myListLeast LstTwo)))    ; fixed parens

If you apply that to your example input of '(2 6 3) and '(4 6 2) the two smallest numbers would be 2 and 2, with a result of 2 * 2 = 4. This is incorrect as the smallest product of '((* 2 4) (* 6 6) (* 3 2)) comes from 3 * 2, which is 6.
(define (smallest-product a b)
  (if (or (null? a) (null? b))                   ; if either list is empty
      +inf.0                                     ; return base case
      (min (* (car a) (car b))                   ; otherwise min of 1st product
           (smallest-product (cdr a) (cdr b))))) ; and the recursive result

(define (min a b)
  (if (< a b)       ; if a is less than b
      a             ; return a
      b))           ; otherwise b

(smallest-product '(2 6 3) '(4 6 2))

6.0

If an empty list is given as input, there can be no minimum product. In this scenario positive infinity, +inf.0, is returned -
(smallest-product '() '(5))
(smallest-product '(5) '())
(smallest-product '() '())

+inf.0
+inf.0
+inf.0

Scheme/Racket is markedly different from languages in the C/Java family.  It is very beginner friendly but you will struggle if you try to bring practices you acquired from other languages. Taking the time to learn this powerful language has improved my programming skills in all other languages. Leave everything at the door and you will receive the greatest benefit.

Thank you so much for the advice regarding learning new languages - I deeply appreciate it. I will make sure to practice the important point you made regarding bringing practices from different languages to others. Once again, thank you!
