Reputation: 178
How would I go about adding values from a tab delimited string to a plist?
(dolist (x *lines*) (cl-ppcre:split "\t" x))
*lines*
is a list of tab delimited strings loaded from a file, and I want to make a plist of the form
(:a value1 :b value2 :c value 3)
Thanks!
Upvotes: 2
Views: 590
Reputation: 4469
You should read the lines from the file, CL-PPCRE:SPLIT them to get the list, and step through this list:
(loop
for (key value) on (cl-ppcre:split " " "a value1 b value2 c value3") by #'cddr
appending (list (intern (string-upcase key) (find-package :keyword))
value))
Upvotes: 2
Reputation: 139381
(let ((line '("foo" "bar" "baz")))
(loop for item in line and key in '(:a :b :c) collect key collect item))
=> (:A "foo" :B "bar" :C "baz")
(mapcan 'list '(:a :b :c) '("foo" "bar" "baz"))
=> (:A "foo" :B "bar" :C "baz")
Upvotes: 5