Created
August 28, 2018 13:03
-
-
Save sarathsp06/187d8b9b58e82cfccb7bf0066dc55427 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yigeleg
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var lst = function(array){return array.slice(-1);} | |
var head = function(array){return array.slice(0,-1);} | |
function CreateTree(key){ | |
keys = key.split('.') | |
tags = {} | |
var last = lst(keys) | |
var hd = head(keys) | |
while(hd.length!==0){ | |
tags[hd.join(".")] = last[0] | |
last = lst(hd) | |
hd = head(hd) | |
} | |
return tags | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var lst = function(array){return array.slice(-1);} | |
var head = function(array){return array.slice(0,-1);} | |
function CreateTree(key){ | |
keys = key.split('.') | |
tags = {} | |
var last = lst(keys) | |
var hd = head(keys) | |
while(hd.length!==0){ | |
tags[hd.join(".")] = last[0] | |
last = lst(hd) | |
hd = head(hd) | |
} | |
return tags | |
} | |
</script></body> | |
</html> |
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
var lst = function(array){return array.slice(-1);} | |
var head = function(array){return array.slice(0,-1);} | |
function CreateTree(key){ | |
keys = key.split('.') | |
tags = {} | |
var last = lst(keys) | |
var hd = head(keys) | |
while(hd.length!==0){ | |
tags[hd.join(".")] = last[0] | |
last = lst(hd) | |
hd = head(hd) | |
} | |
return tags | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment