Hi Dean,

first of all, could you please try to produce some readable, Lisp-style
formatted code for your posts? If possible, boiled-down and simplified
to the essence?


On Sat, Dec 10, 2016 at 10:01:18PM +0000, dean wrote:
> The following program shows me trying to extract a function name from a
> "string" and execute the function using the string.
> The function is called some_fn.
> If I type (some_fn) directly...all is well.
> When I first executed (Fn) that I THOUGHT held the function name...it
> didn't so I dropped into the REPL and played until I got (some_fn) returned
> i.e. by (str (glue "" Fn)) i.e. -> (some_fn)
> I thought putting this in my program would call some_fn but it doesn't and
> I don't understand why.
> Thank you in anticipation
> Dean
> 
> (setq Lmnu
>     '(mAin_mnu-some_fn))
> 
> (de some_fn ()
>    (prinl "yes in some_fn"))
> 
> (de lmnu_to_mnu_tbl (Lmnu Lkey)
>    (for Ele Lmnu
>         (
>             ifn (car Ele)
>             (prog
>                (setq Optn_fn_pair (split (chop Ele) '-))
>                (setq Optn (get Optn_fn_pair 1))
>                (setq Fn (get Optn_fn_pair 2))
> 
>                (some_fn) #this worked fine
> 
> #!
> #: (Fn)         #this didn't 'cos Fn contained "s" "o" "m".....
> #-> "n"
> #: (glue "" Fn)
> #-> "some_fn"
> #: (str (glue "" Fn))   #this looked to evaluate to (some_fn) which worked
> above
> #-> (some_fn)
> 
>                #(str (glue "" Fn)) #but executing it didn't call some_fn
>                #((str (glue "" Fn))) #nor did evaluating what got returned
>             )
>             (prog
>                # (printsp Ele 'is 'a 'list)
>                # (prinl)
>             )
>          )
>    )
> )
> 
> (debug 'lmnu_to_mnu_tbl)
> (lmnu_to_mnu_tbl Lmnu ())


If I get you right, you have a symbol 'mAin_mnu-some_fn', and want to extact
the part after the "-" and execute it as a function? Then you could

   ((intern (pack (cadr (split (chop 'mAin_mnu-some_fn) "-")))))


Or, if you want to keep the function in a variable 'F'

   (let F (intern (pack (cadr (split (chop 'mAin_mnu-some_fn) "-"))))
      (F) )

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to