Добавить
Уведомления

Project Euler Problem 1 in Python, Javascript, Clojure, and Haskell (I don't know Haskell)

Solving Problem 1 of Project Euler in Python, Javascript, Clojure, and Haskell (which I attempt to pick up live in this video). Hope that the stream-of-consciousness commentary is sufficiently intelligible. Timestamps: 00:18 Python 02:51 Javascript 06:35 Clojure 09:24 Haskell Notes: [Javascript] [...Array(n).keys()] includes 0. This was not an issue in this specific problem as 0 is neither divisible by 3 nor 5, but do keep this in mind. [Clojure] The transducer solution in Clojure was slower than the simpler filter+reduce solution due to transducers having additional overhead. If one is chaining multiple operations using the map construct, then transducers *may* lead to speed gains. “Premature optimization is the root of all evil” - Don Knuth (probably) [Haskell] I used stack to initialise the Haskell script as I did not want to find the proper boilerplate to write for Haskell scripts. Furthermore, the Haskell solution is unlikely to be idiomatic.

Иконка канала JavaScript С Основами
22 подписчика
12+
16 просмотров
2 года назад
12+
16 просмотров
2 года назад

Solving Problem 1 of Project Euler in Python, Javascript, Clojure, and Haskell (which I attempt to pick up live in this video). Hope that the stream-of-consciousness commentary is sufficiently intelligible. Timestamps: 00:18 Python 02:51 Javascript 06:35 Clojure 09:24 Haskell Notes: [Javascript] [...Array(n).keys()] includes 0. This was not an issue in this specific problem as 0 is neither divisible by 3 nor 5, but do keep this in mind. [Clojure] The transducer solution in Clojure was slower than the simpler filter+reduce solution due to transducers having additional overhead. If one is chaining multiple operations using the map construct, then transducers *may* lead to speed gains. “Premature optimization is the root of all evil” - Don Knuth (probably) [Haskell] I used stack to initialise the Haskell script as I did not want to find the proper boilerplate to write for Haskell scripts. Furthermore, the Haskell solution is unlikely to be idiomatic.

, чтобы оставлять комментарии