summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules/java/org/apache')
-rw-r--r--sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java
index 6d559f370a..2366d79af6 100644
--- a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java
+++ b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java
@@ -117,6 +117,13 @@ public class IterableUtil {
}
/**
+ * Return the cdr of the cdr of the cdr of a list.
+ */
+ public static <T> Iterable<T> cdddr(final Object l) {
+ return cdr(cdr(cdr(l)));
+ }
+
+ /**
* Return the car of the cdr of the cdr of a list.
*/
@SuppressWarnings("unchecked")
@@ -125,6 +132,24 @@ public class IterableUtil {
}
/**
+ * Return the car of the cdr of the cdr of the cdr of a list.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T cadddr(final Object l) {
+ return (T)car(cdddr(l));
+ }
+
+ /**
+ * Appends a list and another list.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Iterable<T> append(final Object a, final Object b) {
+ if (isNil(a))
+ return (Iterable<T>)b;
+ return cons(car(a), append(cdr(a), b));
+ }
+
+ /**
* Return the first pair matching a key from a list of key value pairs.
*/
public static <T> Iterable<T> assoc(final Object k, final Object l) {
@@ -352,6 +377,11 @@ public class IterableUtil {
assert car(al) == Integer.valueOf(1);
assert cadr(al) == Integer.valueOf(2);
assert caddr(al) == Integer.valueOf(3);
+
+ final Iterable<Object> a = list(0, 1, 2);
+ final Iterable<Object> b = list(3, 4);
+ final Iterable<Object> ab = append(a, b);
+ assert ab.toString().equals("[0, 1, 2, 3, 4]");
return true;
}
}