diff hshhlp.R @ 0:3afe41d3e9e7 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit bb4d3e23d99828bfee16d31d794c49a17313ec2f
author prog
date Mon, 11 Jul 2016 09:12:03 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hshhlp.R	Mon Jul 11 09:12:03 2016 -0400
@@ -0,0 +1,20 @@
+# Function for testing if a key exists inside a list/hashmap
+hHasKey <- function(h, k) {
+	return(length(which(names(h) == k)) > 0)
+}
+
+# Function for getting a boolean value from a list/hashmap
+hGetBool <- function(h, k) {
+	if (hHasKey(h, k)) return(h[[k]]) else return(FALSE)
+}
+
+# keys      A list of keys.
+# values    A list of values.
+# RETURN    A hash using keys as keys and values as values.
+hCreate <- function(keys, values) {
+	h <- list()
+	sz <- min(length(keys), length(values))
+	for(i in 1:sz)
+		h[ keys[[i]] ] <- values[i]
+	return(h)
+}