summaryrefslogtreecommitdiff
path: root/src/FunctionUtils.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/FunctionUtils.scala')
-rw-r--r--src/FunctionUtils.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/FunctionUtils.scala b/src/FunctionUtils.scala
new file mode 100644
index 0000000..3d6610c
--- /dev/null
+++ b/src/FunctionUtils.scala
@@ -0,0 +1,19 @@
+package ixee.cryptopals.utils
+
+object FunctionUtils {
+ // Because doing (_ f _).tupled confuses the inferencer...
+ def tup[A, B, C](f: (A, B) => C): ((A, B)) => C = f.tupled
+
+ def ident[A]: A => A = { x => x }
+
+ implicit class Compositor[A, B](f: A => B) {
+ def :|[C](g: B => C): A => C = f.andThen(g)
+ }
+
+ implicit class Tap[A](x: A) {
+ def tap(f: A => Any): A = {
+ f(x)
+ x
+ }
+ }
+}