Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackwakhu/introduction-to-functional-programming
introduction to functional programming
https://github.com/blackwakhu/introduction-to-functional-programming
clojure functional-programming replit tutorial tutorial-code
Last synced: about 1 month ago
JSON representation
introduction to functional programming
- Host: GitHub
- URL: https://github.com/blackwakhu/introduction-to-functional-programming
- Owner: blackwakhu
- License: mit
- Created: 2024-07-29T06:19:03.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T07:06:20.000Z (5 months ago)
- Last Synced: 2024-10-13T10:20:57.828Z (2 months ago)
- Topics: clojure, functional-programming, replit, tutorial, tutorial-code
- Language: Clojure
- Homepage: https://replit.com/@shiberoderrickw/ElatedWelcomeInstitute
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction to functional programming with clojure
This is an existing branch that I am really existed to try.
## Basics of clojure
We begin by the hello world code
```clojure
(println "hello world")
```
we can also add some comments
```clojure
;; this is a hello world function
```
### Basic math operations
This includes the following designs
1. Addition
```clojure
(+ 1 2)
```
2. Subtraction
```clojure
(- 2 1)
```
3. Multiplication
```clojure
(* 5 2)
```
4. Division
```clojure
(/ 10 2)
```
5. Modulo
```clojure
(mod 5 3)
```
### functions
1. basic functions with no parameters
```clojure
(defn hello-world [] (println "hello world"))
(hello-world)
```
2. function with a single parameter
```clojure
(defn say-hello [name] (println "hello "name))
(say-hello "derrick")
```
3. function with different arity
```clojure
(defn messenger
([] (println "no name to send to"))
([name] (println "sending to "name))
)(messenger)
(messenger "derrick")
```
4. function with many parameters
```clojure
(defn write-names [fname surname] (println "hello" fname surname))(write-names "derrick" "shibero")
```
5. variadic functions i.e. functions with many variables
```clojure
(defn hello [greeting & who]
(println greeting who)
)
(hello "Hello" "world" "class")
```
6. anonymous functions
```clojure
((fn [word](println "the programming language is"word)) "clojure")
```