on-internet
← Community

Scheme - Iterating Over Two Lists

Stack Overflow ·

Hi all I am new at learning Scheme and often have issues with making parallels between an imperative language and a functional language. For example if I had had two arrays. A = [1 2 3] B = [4 5 6] If I wanted to create a new array with the elements of A multiplied by each element in B I could simply do something like (pseudo-code): for(int i = 0; i < A.length; i++) for(int j = 0; j < B.length, j++) arr.push(A[i]*B[j]) Which would give back: arr = [4 5 6 8 10 12 12 15 18] What would be some ways to approach this problem in a functional language?

Comments

Sign in or sign up to comment and upvote.

No comments yet.