On 5/13/06, Beni Cherniavsky <[EMAIL PROTECTED]> wrote:
> On 5/12/06, Beni Cherniavsky <[EMAIL PROTECTED]> wrote:
[...]
word_concat(a, 1) -> a1
list_concat([a b], [1 2]) -> [a b 1 2]
word_product([a b], [1 2]) -> [a1 a2 b1 b2]
list_product([a b], [1 2]) -> [a 1 a 2 b 1 b 2]
word_parallel([a b], [1 2]) -> [a1 b2]
list_parallel([a b], [1 2]) -> [a 1 b 2]

Good points!


[...]
word_concat() doesn't really exist because words are built from items
like variable expansion that produce lists. In fish, it's a special
case of word_product().  [...]

Is it something like this?

   function strcat
       for a in $argv
           printf "%s" $a
       end
   end


The top level of a command line is list_concat() but it's not
availiable otherwise.

  set ar3 $ar1 $ar2


list_product() is availiable through braces but in a surprising way.
[reordered]
[It is] sometimes useful: ``fgrep {-f,(ls *.words)}`` expands to
``fgrep -f some.words -f more.words``

How often is it useful, really?  You can achieve the fgrep expression as

   fgrep -f' '{ls *.words}

and handle cases with three arrays, inline as

   for a in $arr1
       for b in $arr2
           for c in $arr3
               echo $a\n$b\n$c
           end
       end
   end

[...]
Note that all implementations using external commands suffer from
false splitting if any word contains newlines.
[...]

To avoid this, you can use "set newArray[$i] oldArray1[$j]", instead
of "echo".

[...] I hacked perlish references int the flat data structures of fish.
[...]

Well, if we want a function, we have to use the array names, as in
your implementations.

   function interleave_arrays -d 'Interleave the arrays named by the arguments'
       set i 1
       for j in (seq (count $$argv[1]))
           for k in (seq (count $argv))
               set arr[$i] $$argv[$k][$j]
               set i (echo $i+1 | bc)
           end
       end
   end


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to