Re: How to randomize a list?

2018-01-15 Thread Christopher Stone
On 01/14/2018, at 15:31, Sam Hathaway > wrote:
> Try replacing the contents of your “Randomize” text filter with:
> #!/usr/bin/env perl
> use List::Util 'shuffle';
> print shuffle();


Hey Vlad,

I'm with Sam, although I'd write it slightly differently.

#!/usr/bin/env perl -sw
use List::Util 'shuffle';
print shuffle <>;

The main thing here is to turn on the strict and warnings switches, although 
I've also abbreviated STDIN and used a less formal call to shuffle().

--
Take Care,
Chris


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: How to randomize a list?

2018-01-15 Thread Sam Hathaway

On 15 Jan 2018, at 0:46, Vlad Ghitulescu wrote:

(sorry for the following dumb questions… I've used Linux last time 
in 1993! :-)

What are the GNU Coreutils good for?

Should I install them too? (I've read about the difference in the 
performance of the various randomizer solutions in the previous cited 
StackOverflow-threads)

And if so, how?


They provide roughly the same functionality as the standard UNIX 
utilities that come with macOS. (Which come from a BSD lineage.) I like 
them because I used Linux for years and get tripped up by the 
differences in the command-line interfaces. If you don’t have this 
problem, then I don’t think there’s a good reason to install the GNU 
versions.


The Perl solution should be fine for your purposes. It will randomize 
correctly (unlike `sort -R`, which actually sorts by an arbitrary, but 
not random, characteristic of the data), and performance should be 
acceptable.


That worked even whitout making the file Randomize.sh executable with 
chmod +x Randomize!

Take a look:

Vlads27iMac2012:Text Filters Vlad$ ls -al
total 48
drwxr-xr-x@  5 Vlad  staff  170 14 Jan 21:17 .
drwxr-xr-x@ 17 Vlad  staff  578 15 Jan 06:44 ..
-rwxr-xr-x@  1 Vlad  staff  111  1 Nov  2016 
Delete_Viewed_Video_in_Lynda_TOC.pl

-rwxr--r--@  1 Vlad  staff   69 15 Jan 06:32 Randomize.sh
-rwxr-xr-x@  1 Vlad  staff   80  4 Nov  2015 
Selection_To_Numbered_List.sh


How is this possible?


See the `x` in column 4? That indicates that `Randomize.sh` is in fact 
executable, _by the owner_ (you). BBEdit also runs as you, so it can 
execute the script just fine.


Just a note: BBEdit doesn’t care, but to avoid future human confusion 
you might want to change `Randomize.sh` to `Randomize.pl` since it’s a 
Perl script now.

-sam

--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: How to randomize a list?

2018-01-15 Thread Jean-Christophe Helary


> On Jan 15, 2018, at 14:46, Vlad Ghitulescu  wrote:
> 
> What are the GNU Coreutils good for?

They are common Linux utilities of which some BSD equivalents are present on 
macOS.

https://www.gnu.org/software/coreutils/manual/coreutils.html

> Should I install them too? (I've read about the difference in the performance 
> of the various randomizer solutions in the previous cited 
> StackOverflow-threads)
> And if so, how?

homebrew

https://apple.stackexchange.com/questions/69223/how-to-replace-mac-os-x-utilities-with-gnu-core-utilities

> That means that the "stock macOS" on my Sierra 10.12.6 are older than… what?

:) High Sierra ?

I never used sort -R before, but as I wrote the manual has 2015 as a date and 
Sierra was released in 2016, so I guess Apple saw fit to upgrade sort for High 
Sierra.

Would you mind checking the date at the end of the sort man page on your 
machine?


Jean-Christophe Helary
---
@brandelune http://mac4translators.blogspot.com


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.