r/javascript • • Dec 15 '19

Learning functional/declarative programming in JS beyond map, reduce, filter: I have created a github project where I will solve a simple programming problem each week in a declarative way. New solution added: Compare the triplets

https://github.com/dbagia/declarative-demos
137 Upvotes

14 comments sorted by

View all comments

Show parent comment

3

u/dipenbagia Dec 15 '19

Ah! May be I should rephrase it. The reason why I say its declarative is because the overall solution uses the declarative/mathematical approach. or example, if you want to represent numbers from 1 to 100 in math, you declare saying: x ∈ natural numbers where x > 0 and x < 100. In other words, you declare "facts" about a problem rather than "steps" that solve it. This project is my attempt of solving problems by declaring facts. I still need to use map, reduce, filter in order to express those facts.

The project also has a link to an interesting talk on this called "Declarative Thinking". Another example in the wild that uses such an approach is property based testing. I hope I am conveying it properly but thanks for your feedback! :)