Hi everyone! I’m new to daml and I’m working through the tutorial at this link: https://daml.talentlms.com/. I’m currently on lab 2 question 2. The prompt is:
Write a function named termFrequency that takes a word and a string of words and returns the frequency of that word in the string. For example,
debug $ termFrequency “long” “a long long way to run”
should print
0.3333333333
I was able to get the string into a list and the length of the list, but I can’t seem to use the filter function properly to get the list to be just the word I’m looking for. The closest I’ve been able to get so far is this:
wordList = “a long long way to run”
sepWords = words(wordList)
filtList = DA.List.filter(\x → x.sepWords /= “long”)
Also, for learning purposes I think an answer key for the labs would be super helpful as well as maybe putting examples of how the functions are used in the documentation or at least the proper syntax of how to apply the functions.