Skip to content

Instantly share code, notes, and snippets.

@codethereforam
Created December 29, 2020 09:40
Show Gist options
  • Save codethereforam/369e6f45eea94c5d7f1f06f91da4eb5e to your computer and use it in GitHub Desktop.
Save codethereforam/369e6f45eea94c5d7f1f06f91da4eb5e to your computer and use it in GitHub Desktop.
implements scheme's cons in java
/**
* 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