Not sure what you want...

I find this description of "procedure?" at https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_8.html

essential procedure: procedure? obj

Returns #t if obj is a procedure, otherwise returns #f.

(procedure? car)            =>  #t
(procedure? 'car)           =>  #f
(procedure? (lambda (x) (* x x)))
                            =>  #t
(procedure? '(lambda (x) (* x x)))
                            =>  #f
(call-with-current-continuation procedure?)
                            =>  #t

The J "foreign" 4!:0 returns the part of speech of a boxed string,  or set of boxed strings.
I happen to have a verb "rep" and a noun "q" in my session.  So:
   4!:0 'rep';'q'
3 0
So we can test if names are names of verbs:  (fixed width font best here)
  (3 = 4!:0 @< ) each ;:'rep q'
┌─┬─┐
│1│0│
└─┴─┘

So this simple illustrative function MIGHT be useful - there are tacit ways to do the same thing -

procquery =: 3 : 0
obj =. y
if. (3 = 4!:0 @{.@;: ) obj do.
   ". obj
else.
   'false'
end.
)

with these results on my verb rep and noun q:
   procquery 'rep 2 7'  NB. period of repeating decimal 2/7
6
   procquery 'q 2 7'     NB. meaningless...
false

I see Raul has just posted too.  Should be more useful...

Cheers,

Mike

On 16/01/2020 19:55, Raoul Schorer wrote:
Hi,

I am translating scheme code that makes heavy use of delayed evaluation
(thunks). In scheme, there is a predicate 'procedure?' that returns a
boolean. I translated that into a check for a boxed string, which is the
representation I use for delayed procedures, which I then 'force' using ".@>


    1. Is there a better way than building a program string to get delayed
    eval? I tried using (3: '(delayed_verb)"_'), but the interpreter seems to
    greedily eval the whole thing with that pattern. The only working solution
    I found was to convert everything to string.
    2. Is there a general test similar to 'procedure?' in J?


Thanks!
Raoul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to