Clojure tutorial - use an atom to make a run once function wrapper!

Опубликовано: 15 Октябрь 2024
на канале: Daniel Amber
2,345
132

Hey guys! I’m super amped to have made a video with Peter, the guy who introduced me to Clojure :) He is also the author of a number of Clojure libraries https://github.com/ptaoussanis

This video covers solving a problem using Clojure. The problem here being the need for a function that can only run once.

This video covers problem-solving, creating good docstrings, using atoms, and checking thread safety.

This video was super exciting to make and I think it turned out really well. The follow-up to this video will be launched next week, as the total film time was really long so I think it was better to split the videos up.

Gist: https://gist.github.com/danownsthissp...

part 2:    • Clojure tutorial - Create a rate limi...  
part 3:    • Clojure Tutorial - Thread Safety with...  

----

00:00 intro
01:00 setup
01:48 going over idea
02:33 create function to limit
03:42 make function that can only be called once
07:37 atom naming convention
11:06 creating a doc string
13:27 implementing code
13:43 using compare and set
16:00 testing the function
16:33 add arguments to nullary function
18:50 checking thread safety
19:42 end once function