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
def abs(x: Number)(ensure out >= 0): Real = | |
x | |
|> non-zero-parts() | |
|> map(fn(x) => x ^ 2) | |
|> sum() | |
|> sqrt() | |
specialize def abs(x: Real): Real = | |
if x < 0 { -x } else { x } |
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
def abs(x: Number)(ensure out >= 0): Real = | |
x | |
|> non-zero-parts() | |
|> map(fn(x) => x ^ 2) | |
|> sum() | |
|> sqrt() | |
specialize def abs(x: Real): Real = | |
if x < 0 { -x } else { x } |
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
print "gist not found"; |
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
$1 == "File" && $2 ~ /helloworld\// { | |
print "\033[1;33m" $0 "\033[0m"; | |
next; | |
} | |
{ print } |
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
print $!{$!}; |
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
#include <algorithm> | |
#include <cstddef> | |
#include <cmath> | |
#include <iostream> | |
#include <unordered_set> | |
#include <vector> | |
struct field { | |
std::size_t size; | |
std::size_t alignment; |
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
import invalid._ | |
sealed abstract class UserValidationError | |
case object FirstNameEmpty extends UserValidationError | |
case object LastNameEmpty extends UserValidationError | |
def createUser(saveUser: User => UserID)(firstName: String, lastName: String) = | |
validate( | |
firstName.isEmpty -> FirstNameEmpty, | |
lastName.isEmpty -> LastNameEmpty |
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
def saveUser(ds: DataSource)(user: User): UserID = { | |
// blabla | |
} | |
abstract class UserValidationError | |
case object FirstNameEmpty extends UserValidationError | |
case object LastNameEmpty extends UserValidationError | |
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = { | |
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success |
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
def saveUser(ds: DataSource)(user: User): UserID = { | |
// blabla | |
} | |
abstract class UserValidationError | |
case object FirstNameEmpty extends UserValidationError | |
case object LastNameEmpty extends UserValidationError | |
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = { | |
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success |
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
def saveUser(ds: DataSource)(user: User): UserID = { | |
// blabla | |
} | |
abstract class UserValidationError | |
case object FirstNameEmpty extends UserValidationError | |
case object LastNameEmpty extends UserValidationError | |
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = { | |
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success |