Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
Christopher Bottoms's user avatar
Christopher Bottoms's user avatar
Christopher Bottoms's user avatar
Christopher Bottoms
  • Member for 9 years, 2 months
  • Last seen more than a month ago
Stats
3,812
reputation
342k
reached
4
answers
10
questions
Loading…
About

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

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

A good explanation of creating good reproducible R questions

How to get help in R


Python 3 vs Raku

Python 3: Unordered common lines between two files:

#!/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

Raku: Unordered common lines between two files:

#!/bin/env raku

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 Unicode intersection symbol. The ASCII version (&) also works.

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

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

    <fileA>    file name
    <fileB>    file name

Raku tidbits

Raku is a very clean, concise, understandable language. Its design pulls from the strengths of other languages.

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

Error handling example.

SLURM

Pass variables to SLURM: https://stackoverflow.com/questions/45592730

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

convert Jupyter notebook (https://stackoverflow.com/a/50567584/215487)

jupyter-nbconvert --to python notebook.ipynb --stdout --TemplateExporter.exclude_input_prompt=True

Why adjusted P-values are so important: https://www.xkcd.com/882

6
gold badges
22
silver badges
33
bronze badges
106
Score
1
Posts
7
Posts %
106
Score
1
Posts
7
Posts %
8
Score
2
Posts
14
Posts %
8
Score
2
Posts
14
Posts %
8
Score
2
Posts
14
Posts %
3
Score
2
Posts
14
Posts %
Top posts
View all questions and answers