001 package fj.function; 002 003 import fj.F; 004 import fj.F2; 005 import static fj.Function.curry; 006 import static fj.pre.Semigroup.longAdditionSemigroup; 007 import static fj.pre.Semigroup.longMultiplicationSemigroup; 008 009 import static java.lang.Math.abs; 010 011 /** 012 * Curried functions over Longs. 013 * 014 * @version %build.number%<br> 015 * <ul> 016 * <li>$LastChangedRevision: 122 $</li> 017 * <li>$LastChangedDate: 2009-04-25 08:24:38 +1000 (Sat, 25 Apr 2009) $</li> 018 * </ul> 019 */ 020 public final class Longs { 021 private Longs() { 022 throw new UnsupportedOperationException(); 023 } 024 025 /** 026 * Curried Long addition. 027 */ 028 public static final F<Long, F<Long, Long>> add = longAdditionSemigroup.sum(); 029 030 /** 031 * Curried Long multiplication. 032 */ 033 public static final F<Long, F<Long, Long>> multiply = longMultiplicationSemigroup.sum(); 034 035 /** 036 * Curried Long subtraction. 037 */ 038 public static final F<Long, F<Long, Long>> subtract = curry(new F2<Long, Long, Long>() { 039 public Long f(final Long x, final Long y) { 040 return x - y; 041 } 042 }); 043 044 /** 045 * Negation. 046 */ 047 public static final F<Long, Long> negate = new F<Long, Long>() { 048 public Long f(final Long x) { 049 return x * -1L; 050 } 051 }; 052 053 /** 054 * Absolute value. 055 */ 056 public static final F<Long, Long> abs = new F<Long, Long>() { 057 public Long f(final Long x) { 058 return abs(x); 059 } 060 }; 061 062 /** 063 * Remainder. 064 */ 065 public static final F<Long, F<Long, Long>> remainder = curry(new F2<Long, Long, Long>() { 066 public Long f(final Long a, final Long b) { 067 return a % b; 068 } 069 }); 070 }