Skip to content

Instantly share code, notes, and snippets.

@k-marin
k-marin / gist:430716b3148c3a0b163e1b8d9ae5560e
Created September 25, 2020 17:45
Swift when-then-else
// Just an experiment for composing if else in a more structured way
// usage
var isLoadMoreAllowed = false
func loadMore() {
print("loading more")
}
when(isLoadMoreAllowed)
.then { loadMore() }
<!DOCTYPE html>
<html>
<body>
<h2>The XMLHttpRequest Object</h2>
<div id="container"></div>
<p id="demo">Let AJAX change this text.</p>
</div>
//https://github.com/bow-swift/bow/blob/1ba8474eb3ae4c0344f625510818758786d469ac/Sources/Bow/Syntax/Curry.swift
public func curry<A, B, C>(_ fun: @escaping (A, B) -> C) -> (A) -> (B) -> C {
return { a in
return { b in
return fun(a, b)
}
}
}
public func curry1<A, B, C>() -> ( @escaping (A, B) -> C) -> (A) -> (B) -> C {