Created
December 29, 2020 09:40
-
-
Save codethereforam/369e6f45eea94c5d7f1f06f91da4eb5e to your computer and use it in GitHub Desktop.
implements scheme's cons in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Cons | |
* | |
* @author yanganyu | |
* @date 2019/11/12 23:57 | |
*/ | |
public class Cons<L, R> { | |
private L left; | |
private R right; | |
public Cons() { | |
} | |
public Cons(L left, R right) { | |
this.left = left; | |
this.right = right; | |
} | |
/** | |
* get the left element | |
* | |
* @return the left element | |
*/ | |
public L car() { | |
return this.left; | |
} | |
/** | |
* get the right element | |
* | |
* @return the right element | |
*/ | |
public R cdr() { | |
return this.right; | |
} | |
public void setLeft(L left) { | |
this.left = left; | |
} | |
public void setRight(R right) { | |
this.right = right; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment