- Recursion is when a function calls itself.
- A recursive algorithm must have a base case, which is a state that tells the recursive function to stop calling itself and return a value
- The Fibonacci numbers are a sequence of integers in which the first two elements are 0 & 1, and each following elements are the sum of the two preceding elements:
- 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ..., 233
fibo(n) = fibo(n-1) + fibo(n-2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logseq.bb-tasks.nbb.cached-db | |
"Handles nbb side of cached-db functionality. File path and cache implementation | |
encapsulated in this ns" | |
(:require [datascript.transit :as dt] | |
[datascript.core :as d] | |
[logseq.graph-parser.cli :as gp-cli] | |
[logseq.graph-parser :as graph-parser] | |
[clojure.string :as string] | |
[logseq.db.rules :as rules] | |
[clojure.edn :as edn] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
return res.send('Received a GET HTTP method'); | |
}); | |
app.post('/', (req, res) => { | |
return res.send('Received a POST HTTP method'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Roman to Integer | |
https://leetcode.com/explore/interview/card/top-interview-questions-easy/102/math/878/ | |
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. | |
Symbol Value | |
I 1 | |
V 5 | |
X 10 | |
L 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Song | Artist | |
---|---|---|
Like a Rolling Stone | Bob Dylan | |
(I Can't Get No) Satisfaction | The Rolling Stones | |
Imagine | John Lennon | |
What's Going On | Marvin Gaye | |
Respect | Aretha Franklin | |
Good Vibrations | The Beach Boys | |
Johnny B. Goode | Chuck Berry | |
Hey Jude | The Beatles | |
Smells Like Teen Spirit | Nirvana |
I hereby claim:
- I am briansunter on github.
- I am bsunter (https://keybase.io/bsunter) on keybase.
- I have a public key ASBVOoYHoBuiOUESsbkQWkzNtgWfyBubrPz-MUrL_DaC6Qo
To claim this, I am signing this object:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; https://www.hackerrank.com/challenges/ctci-making-anagrams | |
(defn char-frequencies | |
[x] | |
(reduce #(update %1 %2 (fnil inc 0)) {} x)) | |
(let [a (read-line) | |
b (read-line) | |
a-freq (char-frequencies a) | |
b-freq (char-frequencies b) |
Let's say we want to computer the area of some Shape
types like Square
and Circle
We may have some function called sum-areas
that takes a list of Shape
, calls area on each of them, and sums them up. We don't have access to the original source, but want the ability to add new shapes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am brsunter on github. | |
* I am bsunter (https://keybase.io/bsunter) on keybase. | |
* I have a public key ASBzjQ_kiOqWsGQwMPjxucWSWfX4cUoBNTfvhQ0Aaw2Vggo | |
To claim this, I am signing this object: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-posts | |
[ch] | |
(go-loop [a nil] | |
(let [res (get-posts-page a) | |
posts (res :children) | |
after (res :after)] | |
(do | |
(doseq [p posts] | |
(>! ch p)) | |
(recur after))))) |
NewerOlder