I have a problem with common lisp.
I want to pass a string to a function
and want that this strings become a structure.
I can’t use external library.
For example with this input:
(testfu "ftp/http.ok:3345")
This is the struct:
(defstruct test-struct
scheme
part
ans
port)
I want this result:
scheme: “ftp” part: “http” ans “ok” port “3345”
How can I do the testfu ?
here my bad try 🙁
(defun testfu (x)
(setq ur1 (make-test-struct :scheme frist x :host second x)))
You will have to parse the data out of the string in order that you might use it for your strut. Lisp won’t do that magically.
Split Sequence is a good library for doing that
If you don’t want a library, then some code to get you on the correct track. This will tokenize string based on a predicate function fn ( which returns true when a character is a delimiter and false otherwise )
I don’t usually write code for people but here is an example parser, it’s not the most lisp-y, there are better ways of doing this, but it works.