Google also have their own C++ Style Guide that you may find more useful.
I do not use C++.
Pros:
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Functional I/O Demo</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
Google also have their own C++ Style Guide that you may find more useful.
I do not use C++.
Pros:
I hereby claim:
To claim this, I am signing this object:
bject Tag { | |
type Tagged[T] = { | |
type Tag = T | |
} | |
type @@[A, T] = A with Tagged[T] | |
/** | |
* Catch exceptions to create an `Either` value. | |
* | |
* Useful when you want to deal an API that reports failure conditions using | |
* exceptions. This method allows catching exceptions and converting them to | |
* `Left` values. | |
* | |
* An advantage vs using `scala.util.Try` is that you have full control over | |
* which exceptions are caught. | |
* |
externalResolvers <<= resolvers map { rs => | |
Resolver.withDefaultResolvers(rs, scalaTools = false) | |
} |
import java.net.URI | |
/** | |
* State co-monad. | |
* | |
* `Store[F, _]` is the co-monad. | |
*/ | |
final case class Store[F, R](get: F, set: F => R) { | |
def map[S](f: R => S): Store[F, S] = Store(get, f compose set) |
import qualified Data.Map as Map | |
-- Find the most frequently occurring item that occurs more than once | |
-- Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html | |
most :: Ord a => [a] -> Maybe a | |
most xs = fst $ foldl most' (Nothing, Map.empty) xs where | |
most' (winning, seen) x = (winning', seen') where | |
winning' = if count > winningCount then Just x else winning |
import java.util.*; | |
import java.util.stream.Stream; | |
/** | |
* Find the most frequently occurring item that occurs more than once. | |
* Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html | |
*/ | |
public final class Most { |
final case class Outer(inner: Outer#Inner) { | |
final case class Inner(a: String) | |
} |