1

I have a vector of input data given by A <-- Files.Dir '...directory' and this returns a vector of all the files in that directory.

However, the path contains only the file names, not the full paths. What I want to do is to append the path stored in B to each of the elements in A.

How in the hell do I do this?

alvonellos
  • 1,009
  • 1
  • 9
  • 27

1 Answers1

5

You can use the catenate primitive function (dyadic ,) with the each primitive operator (dyadic ¨). An example would look like:

      a
 file00  file01  file02  file03
      b
C:\Path\To\Files
        (⊂b,'\'),¨a
 C:\Path\To\Files\file00  C:\Path\To\Files\file01  C:\Path\To\Files\file02  C:\Path\To\Files\file03

Assuming a windows file system.

Note that catenate requires both its arguments to have the same shape, or be scalars. That is why we had to enclose (⊂) the character vector b so that it became a scalar containing a character vector.

Also note that for completeness I used catenate to add a trailing backslash

⊂b,'\'

The parentheses were only present to ensure that this was run first as APL always evaluates from right to left with the exception of brackets.

Liam Flanagan
  • 408
  • 5
  • 11
  • I figured this question was going to earn me the "tumbleweed" badge! Great answer. Out of curiosity, what development environment do you use? Thanks for the answer. – alvonellos Oct 05 '12 at 15:52
  • Sorry I've just noticed I never replied to this comment. At the time of answering I was working for Dyalog Ltd in Bramley, UK so I would have been using the latest Dyalog APL Interpreter / IDE. I generally ran Windows so it would have been a 64-bit Windows interpreter but Dyalog's interpreter is very cross platform so I would have been using it on multiple environments, I even ported their interpreter to the [Raspberry Pi](http://www.raspberrypi.org/forums/viewtopic.php?f=34&t=46423)! Hope this reply isn't too late =) – Liam Flanagan Jun 18 '14 at 01:00