smartdispatch icon indicating copy to clipboard operation
smartdispatch copied to clipboard

Add more types of folded arguments.

Open MarcCote opened this issue 11 years ago • 6 comments

It would be really nice to handle different type of folded arguments. Here a list of what I think could be useful. Feel free to comment or suggest other types.

Listing

  • [x] List: echo [1 3]
echo 1
echo 3
  • [x] Range:
echo [1:4] echo [1:6:2]
echo 1 echo 1
echo 2 echo 3
echo 3 echo 5
  • [ ] Linspace: echo Lin[1:6:5]
echo 1
echo 2.25
echo 3.5
echo 4.75
echo 6
  • [ ] Logspace: echo Log[0:3:4]
echo 1
echo 10
echo 100
echo 1000

Random sampling

  • [ ] Uniform: echo U[0,1:3]
echo 0.999
echo 0.42
echo 0
  • [ ] Normal: echo N[0,1:4]
echo 1.5
echo -0.42
echo 0.0001
echo -0.9

MarcCote avatar Feb 20 '14 20:02 MarcCote

The remaining ones have been requested over and over. It's pretty simple to implement we just need to think of a nice way to put that in the command line.

mgermain avatar Jun 29 '16 20:06 mgermain

Maybe we could unify all those like so: [1 3] -> List(1,3) [1:6:2] -> Range(1,6,2) Lin[1:6:5] -> Lin(1,6,5) N[0,1:4] -> N(0,1,4)

Not sure though. What do you think @vdumoulin @rizar @caglar ?

mgermain avatar Jun 29 '16 22:06 mgermain

Maybe function names should all be lowercase? Also should we still support [1 3] and [1:6:2] for backward compatibility?

MarcCote avatar Jun 29 '16 22:06 MarcCote

My suggestion is to try to stick to the typical Python syntax as much as possible:

[1 3] -> [1, 3]
[1:6:2] -> ok
Lin[1:6:5] -> Lin(1,6,5)
Log[1:6:5] -> Log(1,6,5)
N[0,1:4] -> N(0,1,4)

I don't have a strong preference on lowercase vs uppercase, but since N has to be uppercase maybe it makes sense to keep Log and Lin uppercase too.

fvisin avatar Jul 12 '16 21:07 fvisin

For me suggestions made by both @mgermain and @fvisin are good. But I think I would prefer having lower case for Lin, Log and N functions.

caglar avatar Aug 16 '16 21:08 caglar

I vote for [] because bash cares about () sometimes.

ieee8023 avatar May 03 '17 23:05 ieee8023