I'm trying to write a
elisp
function like this:
(setq lst '(("abc" . "c") ("cde" . "f")))
(foo "a" lst) ;=>"c"
(foo "b" lst) ;=>"c"
(foo "c" lst) ;=>"c"
(foo "d" lst) ;=>"f"
I know if the first string is same as the key string I can use assoc
.
(setq lst '(("a" . "c") ("d" . "f")))
(cdr (assoc "a" lst)) ;= "c"
(cdr (assoc "d" lst)) ;= "f"
I could enable the function by writing the lst
separately, but I don't think it's the best way to do.
(setq lst '(("a" . "c") ("b" . "c") ("c" . "c")
("c" . "f") ("d" . "f") ("f" . "f")
))
Can someone help me how to write the function like foo
?
Asked by ironsand
(5425 rep)
Nov 10, 2015, 07:02 PM
Last activity: Nov 10, 2015, 08:17 PM
Last activity: Nov 10, 2015, 08:17 PM