diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-01 22:50:55 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-01 22:50:55 -0500 |
| commit | 9528bb145193159fa3e697da642e32a0877af5fb (patch) | |
| tree | 3375b4524d7c845ec33c7636fb7697ce3c1d6a42 /java | |
| parent | 950e3c765e30648de34cfc4f65fffdce06f0727f (diff) | |
| download | mal-9528bb145193159fa3e697da642e32a0877af5fb.tar.gz mal-9528bb145193159fa3e697da642e32a0877af5fb.zip | |
All: pass stepA tests, in particular with correct conj behavior.
Diffstat (limited to 'java')
| -rw-r--r-- | java/src/main/java/mal/types.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/java/src/main/java/mal/types.java b/java/src/main/java/mal/types.java index 1e9bb34..8a4910b 100644 --- a/java/src/main/java/mal/types.java +++ b/java/src/main/java/mal/types.java @@ -716,12 +716,21 @@ public class types { static MalFunction conj = new MalFunction() { public MalVal apply(MalList a) throws MalThrowable { - MalList lst = new MalList(); - lst.value.addAll(((MalList)a.nth(0)).value); - for(Integer i=1; i<a.size(); i++) { - lst.value.add(a.nth(i)); + MalList src_seq = (MalList)a.nth(0), new_seq; + if (a.nth(0) instanceof MalVector) { + new_seq = new MalVector(); + new_seq.value.addAll(src_seq.value); + for(Integer i=1; i<a.size(); i++) { + new_seq.value.add(a.nth(i)); + } + } else { + new_seq = new MalList(); + new_seq.value.addAll(src_seq.value); + for(Integer i=1; i<a.size(); i++) { + new_seq.value.add(0, a.nth(i)); + } } - return (MalVal) lst; + return (MalVal) new_seq; } }; |
