[plt-scheme] My Scheme Probelm
Dear Bilal,
What are you trying to do here?
*(*if (not (equal? (pdg-vertex-ids-killed (caddr z)) #f))
*(*abs-loc-set-traverse (pdg-vertex-ids-killed (caddr z))
(display "to" out-port) *)*
*)*
It looks like you are giving the result of (display "to" out-port) to the
function 'abs-loc-set-traverse'. In this function apparently you're doing
an apply on the result of 'display', which yields the given error.
So, the lambda you've provided should do what you want, or did you
actually want a string as argument (don't use apply on that though ;-).
You can give it "to" then.
--Hans
Bilal, Haider Z schreef:
>
> Dear Colleagues,
>
>
>
> I am a PhD student at LSBU working on 'Measuring Ripple Effect for
> Object oriented software'.
>
> I would be extremely grateful for your, or whoever you recommend,
> assistance on a problem I'm facing and stuck on!
>
> I have familiarized myself with Scheme and currently working on
> writing a Scheme program to list for me all assigned TO and FROM
> variables with their line numbers listed. Apart from the red bolded
> section of my code shown below, which is supposed to display TO or
> FROM to each listed variable appropriately, the rest of my program
> working correctly. However, this section of the code is not working
> properly and giving me the following error: *apply: bad procedure:
> #[undefined]*
>
> * *
>
> *_A Sample Function of the C program being analysed by the tool I am
> using (Codesurfer):_*
>
> *_ _*
>
> /*
> ========================================================================================
> */
>
> /* ===========
> biggest_prime =============== */
>
> /*
> ========================================================================================
> */
>
>
>
> int biggest_prime (root)
>
> new_tree_node *root;
>
> {
>
> /* This function calculates the Biggest prime metric */
>
>
>
> int child;
>
> new_tree_node *parent;
>
>
>
> if ( (*root).prime_name[0] != 'P' && biggest_prime_value <
> (*(*root).prime).num_of_nodes )
>
> biggest_prime_value = (*(*root).prime).num_of_nodes;
>
>
>
> parent = root->children;
>
>
>
> for(child = 0; child < (*root).child_num; child ++)
>
> if (child == 0)
>
> biggest_prime (root->children);
>
> else
>
> {
>
> biggest_prime (parent->siblings) ;
>
> parent = parent->siblings;
>
> }
>
>
>
> return (biggest_prime_value);
>
> }
>
>
>
> *_My Program:_*
>
> (define (assignments)
>
> (define filenumber 1)
>
> (for-each
>
> (lambda(pdg)
>
> (when (eqv? (pdg-kind pdg) 'user-defined)
>
> (let* ((out-port (open-output-file (string-append "Fun"
> (number->string filenumber) "_V.dat"))) (linelist ()))
>
> (pdg-vertex-set-traverse (pdg-vertices pdg)
>
> (lambda(v)
>
> (let* ((fileuid (pdg-compilation-uid
> (pdg-vertex-pdg v))))
>
> (int-pair-set-traverse (pdg-vertex-charpos v)
>
> (lambda(offset w)
>
> (if (not (equal? (pdg-vertex-ids-killed
> v) #f))
>
> (abs-loc-set-traverse
> (pdg-vertex-ids-killed v)
>
> (lambda(y)
>
> (let* ((line-num
> (file-get-line-num fileuid offset)))
>
> (set! linelist (cons (list
> line-num y v) linelist))
>
> )
>
> #t)
>
> )
>
> )
>
> (if (not (equal? (pdg-vertex-ids-used v)
> #f))
>
> (abs-loc-set-traverse
> (pdg-vertex-ids-used v)
>
> (lambda(y)
>
> (let* ((line-num
> (file-get-line-num fileuid offset)))
>
> (set! linelist (cons (list
> line-num y v) linelist))
>
> )
>
> #t)
>
> )
>
> )
>
> #t)
>
> )
>
> )
>
> #t)
>
> )
>
> (set! linelist
>
> (sort linelist
>
> (lambda (a b)
>
> (< (cadar a) (cadar b))
>
> )
>
> )
>
> )
>
> (for-each
>
> (lambda (z)
>
> (let ((linenum (car z)))
>
> (define line-num (car z))
>
> (display (cdr line-num) out-port)
>
> (write-char #\tab out-port)
>
> * (if (not (equal? (pdg-vertex-ids-killed
> (caddr z)) #f))*
>
> * (abs-loc-set-traverse
> (pdg-vertex-ids-killed (caddr z))*
>
> * (display "to" out-port)*
>
> * )*
>
> * )*
>
> * (if (not (equal? (pdg-vertex-ids-used (caddr
> z)) #f))*
>
> * (abs-loc-set-traverse (pdg-vertex-ids-used
> (caddr z))*
>
> * (display "from" out-port)*
>
> * )*
>
> * )*
>
> (newline out-port)
>
> )
>
> )
>
> linelist)
>
> (close-output-port out-port))
>
> (set! filenumber (+ filenumber 1)))
>
> )
>
> (sdg-pdgs))
>
> )
>
> (assignments)**
>
>
>
> *_I have tried to use the lambda function, as shown below:_*
>
> * (if (not (equal? (pdg-vertex-ids-killed
> (caddr z)) #f))*
>
> * (abs-loc-set-traverse
> (pdg-vertex-ids-killed (caddr z))*
>
> * (lambda (x)*
>
> * (display "to" out-port)*
>
> * #t)*
>
> * )*
>
> * )*
>
> * (if (not (equal? (pdg-vertex-ids-used (caddr
> z)) #f))*
>
> * (abs-loc-set-traverse (pdg-vertex-ids-used
> (caddr z))*
>
> * (lambda (x)*
>
> * (display "from" out-port)*
>
> * #t)*
>
> * )*
>
> * )*
>
>
>
> *_However, it gave me wrong output, some had TO and FROM both listed
> together:_*
>
> (257) from
>
> (257) to
>
> (257) from
>
> (258) to
>
> (265) from
>
> (265) fromfrom
>
> (265) fromfrom
>
> (266) tofrom
>
> (266) tofrom
>
> (268) tofrom
>
> (268) tofrom
>
> (270) fromfrom
>
> (270) fromfrom
>
> (270) fromfrom
>
> (270) to
>
> (270) fromfrom
>
> (270) tofrom
>
> (270) tofrom
>
> (271) from
>
> (272) from
>
> (275) from
>
> (276) tofrom
>
> (276) tofrom
>
> (279) tofrom
>
> (279) tofrom
>
>
>
> I would appreciate and value your time in guiding me to what needs to
> be done to correct this problem very much please.
>
>
>
> Thank you.
>
> Yours faithfully,
>
> HZBilal.
>
>
>
> ---
> Mr Haider Zuhair Bilal BEng MSc MIEE MIEEE MBCS
> PhD Research Scholar
> Centre for Systems and Software Engineering
> Faculty of Business, Computing and Information Management
> London South Bank University
> 103 Borough Road
> London SE1 0AA
> UK
>
>
>
> Tel: +44(0)20 7815 7473
> Fax: +44(0)20 7815 7550
> Mobile: +44(0)7887 598355
>
>
>
>
>
>
>
>
> This e-mail message may be confidential and is intended only for the
> use of the individual(s) to whom it is addressed. It may contain
> information which is or may be confidential, non-public or legally
> privileged. Please do not disseminate or distribute this message other
> than to its intended recipient without permission of the author. You
> should not copy it or use it for any purpose nor disclose its contents
> to any other person. If you have received this message in error,
> please notify me by email immediately and delete the original message
> and all copies in your computer systems.
> ------------------------------------------------------------------------
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20061010/353ebc99/attachment.html>