1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package zeus.concepts.fn;
25
26 import java.util.*;
27 import zeus.util.*;
28 import zeus.concepts.*;
29
30 public class RealFn extends ValueFunction
31 implements PrimitiveFn, PrimitiveNumericFn {
32
33 protected double arg;
34
35 public RealFn(double arg) {
36 super(REAL,10);
37 this.arg = arg;
38 }
39 public RealFn(String arg) {
40 super(REAL,10);
41 this.arg = (Double.valueOf(arg)).doubleValue();
42 }
43 public ValueFunction mirror() {
44 return new RealFn(arg);
45 }
46 public String toString() {
47 return Double.toString(arg);
48 }
49 Object getArg(int position) {
50 if (position != 0) throw new ArrayIndexOutOfBoundsException(position);
51 return new Double(arg);
52 }
53 public double getValue() {
54 return arg;
55 }
56 public double doubleValue() {
57 return arg;
58 }
59 public int intValue() {
60 return (int)arg;
61 }
62 public long longValue() {
63 return (long)arg;
64 }
65 public boolean references(ValueFunction var) {
66 return false;
67 }
68 public boolean isDeterminate() {
69 return true;
70 }
71 public boolean equals(Object any) {
72 if ( !(any instanceof ValueFunction) ) return false;
73 ValueFunction fn = (ValueFunction)any;
74 switch( fn.getID() ) {
75 case INT:
76 return arg == ((IntFn)fn).getValue();
77 case REAL:
78 return arg == ((RealFn)fn).getValue();
79 }
80 return false;
81 }
82 public boolean less(Object any) {
83 if ( !(any instanceof ValueFunction) ) return false;
84 ValueFunction fn = (ValueFunction)any;
85 switch( fn.getID() ) {
86 case INT:
87 return arg < ((IntFn)fn).getValue();
88 case REAL:
89 return arg < ((RealFn)fn).getValue();
90 }
91 return false;
92 }
93 ValueFunction unify(ValueFunction fn, Bindings b) {
94 return null;
95 }
96 }