Created
November 7, 2014 11:04
-
-
Save LittleHelicase/974b8ce4d4a997b4026e to your computer and use it in GitHub Desktop.
SubList mit ADTs // source http://jsbin.com/detaya
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SubList mit ADTs</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"]); | |
function subList(L, pos, len){ | |
var newList = new ArrayList(); | |
newList.create(); | |
for(var i=0; i<len; i++){ | |
newList.insert(newList.last(), L.retrieve(pos)); | |
pos = L.next(pos); | |
} | |
return newList; | |
} | |
console.log(listToString(subList(l1,l1.first(),2))); | |
console.log(listToString(subList(l1,l1.next(l1.first()),2))); | |
console.log(listToString(subList(l2,l2.first(),2))); | |
console.log(listToString(subList(l2,l2.next(l2.first()),2))); | |
</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"]); | |
function subList(L, pos, len){ | |
var newList = new ArrayList(); | |
newList.create(); | |
for(var i=0; i<len; i++){ | |
newList.insert(newList.last(), L.retrieve(pos)); | |
pos = L.next(pos); | |
} | |
return newList; | |
} | |
console.log(listToString(subList(l1,l1.first(),2))); | |
console.log(listToString(subList(l1,l1.next(l1.first()),2))); | |
console.log(listToString(subList(l2,l2.first(),2))); | |
console.log(listToString(subList(l2,l2.next(l2.first()),2)));</script></body> | |
</html> |
This file contains hidden or 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
var l1 = new ArrayList(); | |
var l2 = new LinkedList(); | |
createListFromArray(l1, [1,2,3,4]); | |
createListFromArray(l2, ["a","c","b"]); | |
function subList(L, pos, len){ | |
var newList = new ArrayList(); | |
newList.create(); | |
for(var i=0; i<len; i++){ | |
newList.insert(newList.last(), L.retrieve(pos)); | |
pos = L.next(pos); | |
} | |
return newList; | |
} | |
console.log(listToString(subList(l1,l1.first(),2))); | |
console.log(listToString(subList(l1,l1.next(l1.first()),2))); | |
console.log(listToString(subList(l2,l2.first(),2))); | |
console.log(listToString(subList(l2,l2.next(l2.first()),2))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment