126
reputation
4

Christopher Bottoms

I use Python, Perl 6, Perl, R, Java, bash, and anything else that is needed.

Utilizo Python, Perl 6, Perl, R, Java, bash, o lo que sea necesario.

A good explanation of creating good reproducible R questions

How to get help in R


Comparison of Python 3 and Perl 6 (both very nice languages)

Python 3: find common lines between two files, regardless of the order:

#!/bin/env python

import argparse

parser = argparse.ArgumentParser(description='Determine the lines in common between two files')

parser.add_argument('fileA', help='file name')
parser.add_argument('fileB', help='file name')

args = parser.parse_args()

with open(args.fileA) as x: linesA = x.readlines()
with open(args.fileB) as x: linesB = x.readlines()

intersection = set(linesA).intersection(set(linesB))

print("".join(sorted(intersection)))

Usage message resulting from python intersection_of_lines.py --help:

usage: intersection_of_lines.py [-h] fileA fileB

Determine the lines in common between two files

positional arguments:
  fileA       file name
  fileB       file name

optional arguments:
  -h, --help  show this help message and exit

Perl 6: find common lines between two files, regardless of the order:

#!/bin/env perl6

sub MAIN #= Determine the lines in common between two files
(   $fileA, #= file name
    $fileB, #= file name
)
{
    my @linesA = $fileA.IO.lines;
    my @linesB = $fileB.IO.lines;

    my $intersection = @linesA ∩ @linesB;

    put $intersection.keys.sort.join("\n");
}

Yes that is , a real intersection symbol, thanks to Unicode support. You can also use (&) for intersection, if your editor has issues with Unicode.

You also get a nice usage message resulting from perl6 intersection_of_lines.p6 --help:

Usage:
  ./intersection_of_lines.p6 <fileA> <fileB> -- Determine the lines in common between two files

    <fileA>    file name
    <fileB>    file name

Perl 6 tidbits

Perl 6 is a very clean, concise, understandable language. It is a new language (not just a different version of Perl). Its design pulls from the strengths of other languages.

Perl 6's rotor (the "king of list manipulation").

Error handling example.

SLURM

Passing environment variables to SLURM: https://stackoverflow.com/questions/45592730

sbatch --export=GREETING=Hello,PLACE=world --wrap='echo "$GREETING $PLACE" > howdy.txt'

0
answers
1
question
~84
people reached
  • Member for 8 years, 7 months
  • 1 profile view
  • Last seen Mar 29 at 15:53

Top tags (1)

Score 0
Posts 1
Posts % 100

Top posts (1) All Questions Answers | Votes Newest

Badges (4)

Gold

Silver

Bronze

4

Rarest