elisp - How can I perform a partial symbol match on a defstruct? -
In this, I have created an employee database and provided the Select-By-First function < / P>
(select-by-first-pattern '' select) If I match any part of the string / symbol, then how do I write choose-by-first-pattern Can i EV);('cl' is required) Returns all record returns with (defvar *) (like Steve)The code required for the creation of the database is: (Updated: Recommended solution) (app-recorder) (Add-records) (Add-records) records (make-worker: age 34: last name 'forequarse: first name' Alice: gender ' Women)) (Junk record (age 43: last name 'jobs: first name' Steve: gender 'male)) (add-write D (make-worker-age-53: last name 'baller: first name' steve: sex 'male)) (pick-by-first (first name) (delete-if -not #' (lambda (employee) Employee-first-name employee) first name)) * emp-db *)) ;; ---------- Answer below ---------- ;; (Select-By-First-Pattern (First Name) Cancel (Delete-If-No #) (Lambda (Employee) (if (String-match first name (Symbol name (employee-first-name employee)) T-zero)) * emp-db *)) (print (first-pattern "al" by selection)); Alice records the record (print (choose-first-first-pattern "Eve");) Two Steve's record returns (print (first-pattern "EE" by selecting); If you want to match partial or pattern, then you should actually use the string. I have no experience with common Lisp, but AMX has the wealth of the REGEX-mailing function.
If you are actually stuck in the form of inputs with symbols, then you get the name of the symbol as a string in
symbol-name
(at least in Elisp) to do. Either way, you're going to end up comparing the strings, so you can start using it.
Comments
Post a Comment