0

I have a function in scheme (extract-disjunct word nodes) that takes two parameters: word and nodes.

I have a sentence: "This is a test sentence". For each word in this sentence I want to apply the above given function.

This can be done with a simple map operation.

However, the catch is this: The second parameter nodes is itself a nested list and the parameter stays the same for a given sentence i.e it will stay the same for the list of words that I intend to apply map to. It won't change.

I want to apply map like this: (map extract-disjunct word nodes)

However, I receive an error. Is there any solution? Can I keep one parameter in map constant?

Rohit Shinde
  • 1,575
  • 5
  • 21
  • 47

1 Answers1

3

Simply define another function that takes the word argument and passes it and a constant nodes argument to extract-disjunct. Using currying, you can make this work for any constant nodes:

(define ((curried-extract-disjunct nodes) word) (extract-disjunct word nodes))

(map (curried-extract-disjunct nodes) words)
Vitruvie
  • 2,327
  • 18
  • 25