apply f to list hangs function



Use of apply ('search_file, alist) hangs the
run of my function search_mfiles (file-or-direc-path,substring, options ),
which uses search_file(file,substring,options) and ls (path).

I test both of the latter two functions below,
but cannot get my use of apply ('search_file, alist) to
work inside a loop in search_mfiles.

----------------------------
 Maxima 5.24.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
                                  2011-06-29


(%i1) display2d:false$
(%i2) load("search_mfiles.mac");
(%o2) "search_mfiles.mac"

/* test use of apply with function search_file  */

(%i3) myL : ["c:/work2/temp1/atext1.txt","is",word,cs]$
(%i4) apply ('search_file,myL);
 2  Is this line two? Yes, this is line two. 
 6  This is line six, Isn't it? 
 
(%o4) "c:/work2/temp1/atext1.txt"

/*  test the  function ls: */
 
(%i5) ls ("c:/work2/temp1/");
(%o5) ["c:/work2/temp1/atext1.txt","c:/work2/temp1/atext2.txt",
       "c:/work2/temp1/calc1news.txt","c:/work2/temp1/ndata1.dat",
       "c:/work2/temp1/stavros-tricks.txt","c:/work2/temp1/text1.txt",
       "c:/work2/temp1/text2.txt","c:/work2/temp1/trigsimplification.txt",
       "c:/work2/temp1/wu-d.txt"]
       
(%i6) print_file ("c:/work2/temp1/atext1.txt");
 
Is this line two? Yes, this is line two.
THIS might be line three.
Here IS line four.
I insist that this be line five.
This is line six, Isn't it?
(%o6) "c:/work2/temp1/atext1.txt"

/* here we run the function
    search_mfiles, with the display outputs shown:  */
    
    
(%i7) search_mfiles ("c:/work2/temp1/","is");

 %fnamea = "c:/work2/temp1/"

%fnL = ["c:/work2/temp1/atext1.txt","c:/work2/temp1/atext2.txt",
        "c:/work2/temp1/calc1news.txt","c:/work2/temp1/ndata1.dat",
        "c:/work2/temp1/stavros-tricks.txt","c:/work2/temp1/text1.txt",
        "c:/work2/temp1/text2.txt","c:/work2/temp1/trigsimplification.txt",
        "c:/work2/temp1/wu-d.txt"]

%ssa = "is"

%vf = "c:/work2/temp1/atext1.txt"

%rrL = ["c:/work2/temp1/atext1.txt","is",word,cs]

/* program hangs here. */

-------------------------------
code for search_mfiles is:

-------------------------------------------
  search_mfiles([%ua]) := 
    block ([%fnamea,%ssa,%wmodea : word,%cmodea:cs,%linesa,
             %flinesa:[],%lssa,%nla:0,%pa,%nfirsta,optLa,%qa,
              %fnL,%vf,%rrL],   
      
      %fnamea : part (%ua,1),
      display (%fnamea),    
  
      %fnL : ls (%fnamea),
      
      display (%fnL),
      
      if not %fnL then return (false),
      if length (%fnL) = 0 then 
        ( disp ("no files found"),
          return (false)),
         
      %ssa : part (%ua,2),
      
      display (%ssa),
      
      if not stringp (%ssa) then (
        disp (" second arg must be a string "),
        return (false)),        
                
      if length (%ua) > 2 then
        ( optLa : apply ('getopts,rest (%ua,2)),        
          if not optL then return(false),
        
        for %qa in optLa do
          if part (%qa,1) = w then
             %wmodea : part (%qa,2)
          else %cmodea : part (%qa,2)),
  
       for %vf in %fnL do
         (  display (%vf),
            %rrL : flatten (cons ([%vf,%ssa],[%wmodea,%cmodea])),
            display (%rrL),
            apply ('search_file,%rrL)))$
       ---------------------------------------------

Any suggestions for a cure??

Ted Woollett