Skip to content

Instantly share code, notes, and snippets.

@LittleHelicase
Created November 5, 2014 21:33
Show Gist options
  • Save LittleHelicase/d0f5ef8cf5866bc0129b to your computer and use it in GitHub Desktop.
Save LittleHelicase/d0f5ef8cf5866bc0129b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<!-- ADT Liste implementiert als ArrayList -->
<script src="http://jsbin.com/cuqure.js"></script>
<!-- ADT Liste implementiert als LinkedList -->
<script src="http://jsbin.com/wowobu.js"></script>
<!-- ADT Liste Hilfsfunktionen. Exportiert
* listToString(L): gibt die Liste aus
* createListFromArray(L,array): erstellt die Liste und füllt sie mit dem Arrayinhalt
-->
<script src="http://jsbin.com/gavum.js"></script>
</head>
<body>
<script id="jsbin-javascript">
var l1 = new ArrayList();
var l2 = new LinkedList();
createListFromArray(l1, [1,2,3,4]);
createListFromArray(l2, ["a","c","b"]);
console.log(listToString(l1));
console.log(listToString(l2));
function rotateList(L,i){
for(var k=0; k<i; k++){
var x = L.retrieve(L.last());
L.deletePos(L.last());
L.insert(null,x);
}
}
rotateList(l1, 2);
rotateList(l2,2);
console.log(listToString(l1));
console.log(listToString(l2));
console.log(l1.retrieve(1));
console.log(l2.retrieve(1));
console.log(l2.retrieve(l2.next(l2.first())));
</script>
<script id="jsbin-source-javascript" type="text/javascript">var l1 = new ArrayList();
var l2 = new LinkedList();
createListFromArray(l1, [1,2,3,4]);
createListFromArray(l2, ["a","c","b"]);
console.log(listToString(l1));
console.log(listToString(l2));
function rotateList(L,i){
for(var k=0; k<i; k++){
var x = L.retrieve(L.last());
L.deletePos(L.last());
L.insert(null,x);
}
}
rotateList(l1, 2);
rotateList(l2,2);
console.log(listToString(l1));
console.log(listToString(l2));
console.log(l1.retrieve(1));
console.log(l2.retrieve(1));
console.log(l2.retrieve(l2.next(l2.first())));</script></body>
</html>
var l1 = new ArrayList();
var l2 = new LinkedList();
createListFromArray(l1, [1,2,3,4]);
createListFromArray(l2, ["a","c","b"]);
console.log(listToString(l1));
console.log(listToString(l2));
function rotateList(L,i){
for(var k=0; k<i; k++){
var x = L.retrieve(L.last());
L.deletePos(L.last());
L.insert(null,x);
}
}
rotateList(l1, 2);
rotateList(l2,2);
console.log(listToString(l1));
console.log(listToString(l2));
console.log(l1.retrieve(1));
console.log(l2.retrieve(1));
console.log(l2.retrieve(l2.next(l2.first())));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment