-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItCons.java
47 lines (41 loc) · 1.53 KB
/
ItCons.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* ItCons.java
* The Lisp 'cons' data structure:
* a cons is a pair:
* - 1st element is returned by car() function
* - 2nd element is returned by cdr() function
* http://en.wikipedia.org/wiki/Conshttp://en.wikipedia.org/wiki/Cons
* ...................................................................................
* SCOM: Single Class Object Model (http://code.google.com/p/scom/)
* Licence: MIT (http://en.wikipedia.org/wiki/MIT_License)
* Michel Kern - 27 may 2012 - 16:54
* Copyright (C) <2012> www.terimakasi.com
*/
package scom.samples.lang.lisp;
import scom.It;
public class ItCons extends It
{
public static final String BASENAME = ItCons.class.getSimpleName();
public static final String CLASS_NAME = ItCons.class.getCanonicalName();
protected ItCons(Object key, Object value, Object next)
{
super(key, value, next);
//System.out.println(" > ScomCons key:" + key + " value:" + value + " option:" + option);
putFacet(ItLisp.CAR, New(It.K_VALUE, value));
putFacet(ItLisp.CDR, New(It.K_VALUE, next));
} // Private Constructor
@Override
public String toString()
{
String to_string = "";
It car_it = getFacet(ItLisp.CAR);
String car_it_str = car_it.toString();
It cdr_it = getFacet(ItLisp.CDR);
String cdr_it_str = cdr_it.toString();
if (cdr_it_str.equals(It.K_NIL))
to_string = car_it.getValue().toString();
else
to_string = "(" + car_it_str + "," + cdr_it_str + ")";
return to_string;
} //---- toString()
} //---------- ItCons