From mark at purdue.edu Sun Sep 1 17:19:42 2019 From: mark at purdue.edu (Mark Senn) Date: Sun, 01 Sep 2019 20:19:42 -0400 Subject: [Purdue-pm] Perl Weekly Challenge Message-ID: <40737.1567383582@pier.ecn.purdue.edu> This week's Perl Weekly Challenge problem was at https://perlweeklychallenge.org/blog/perl-weekly-challenge-023/ It includes recaps of some previous problems by several people. My blog for this week's forward difference task is at https://engineering.purdue.edu/~mark/pwc-023-1.pdf The Perl 6 code: # # Perl Weekly Challenge - 023 # Task #1 # # See # engineering.purdue.edu/~mark/blog/pwc-023-1.pdf # for more information. # # Run using Perl v6.d. use v6.d; # Get command line arguments. my $order = shift @*ARGS; my @x = @*ARGS; my $i = 1; while @x.elems > 1 && $i <= $order { # <<->> is a hyperoperator # if @x = (10,20,30,40), then @x = @x[1..*] <<->> @x[0..^*-1]; # gives (20-10,30-20,40-30) = (10,20,30) say "order {$i++}: {@x}"; } My blog for this week's factoring numbers task is at https://engineering.purdue.edu/~mark/pwc-023-2.pdf The Perl 6 code: # # Perl Weekly Challenge - 023 # Task #2 # # See # engineering.purdue.edu/~mark/blog/pwc-023-2.pdf # for more information. # # Run using Perl v6.d. use v6.d; my $n = 228; # number to factor # for 2, 3, 5, 7, ..., if the number is prime enter the loop for (2, 3, *+2 ... *).grep({.is-prime}) -> $p { while $n %% $p { # $n evenly divisible by the current prime? say $p; # print the prime $n div= $p; # divide $n by the prime } # Is $p > $n.sqrt? # But, I suspect $p ** 2 > $n (= $p * $p > $n) , is faster to compute. if ($p ** 2 > $n) { $n.say; last; } } -mark From mark at purdue.edu Thu Sep 5 10:09:22 2019 From: mark at purdue.edu (Mark Senn) Date: Thu, 05 Sep 2019 13:09:22 -0400 Subject: [Purdue-pm] programming fonts Message-ID: <10032.1567703362@pier.ecn.purdue.edu> Over the past ten years or so, I've evaluated probably around 20 fonts for programming and have used the following (one at a time for months or years). Inconsolata dz Inconsolata g (liked dot in zero better) Adobe Source Code Pro (the ell looks like this only curvier -| | |_ It is hard to mistake it for a one. IBM Plex Mono Regular. I like ( { [ and ] } ) better thn Source Code Pro's version of those glpyhs (an "A" can be represted by a hex number 41 in a computer, a glyph is the pictorial representation or symbol for that character). I don't like the ell in Source Code Pro. It isn't ellish enough to suit me. Ell, 1, and the pipe symbol (|) all look different. Parens, braces, and brackets all look different. Has dotted zero that I like better than slashed zero. Dotted zero and capital oh look different and dotted zero looks different from an eight. It's contemporary. Comes in lots of styles and weights. The LaTeX plex package supports it. Plex has all the Unicode characters I'v tried using from Emacs. It's open-source. Mark Senn, Senior Software Engineer, Engineering Computer Network, Purdue University From mark at purdue.edu Sun Sep 8 10:43:33 2019 From: mark at purdue.edu (Mark Senn) Date: Sun, 08 Sep 2019 13:43:33 -0400 Subject: [Purdue-pm] what proramming fonts do you recommend? Message-ID: <14852.1567964613@pier.ecn.purdue.edu> I'm writing a blog entry about fonts. I'll show pictures of the font along with pictures of other fonts to compare and contrast, etc. I'm only interested in information about free fonts. Do you know of any fonts that are especially good for programming, or especially bad fonts to contrast with the better fonts? Following my signature (i.e., "-mark") is the message I sent to Purdue Perl Mongers earlier about fonts. -mark To: Purdue Perl Mongers From: Mark Senn Subject: programming fonts Date: Thu, 05 Sep 2019 13:09:22 -0400 Over the past ten years or so, I've evaluated probably around 20 fonts for programming and have used the following (one at a time for months or years). Inconsolata dz Inconsolata g (liked dot in zero better) Adobe Source Code Pro (the ell looks like this only curvier -| | |_ It is hard to mistake it for a one. IBM Plex Mono Regular. I like ( { [ and ] } ) better thn Source Code Pro's version of those glpyhs (an "A" can be represted by a hex number 41 in a computer, a glyph is the pictorial representation or symbol for that character). I don't like the ell in Source Code Pro. It isn't ellish enough to suit me. Ell, 1, and the pipe symbol (|) all look different. Parens, braces, and brackets all look different. Has dotted zero that I like better than slashed zero. Dotted zero and capital oh look different and dotted zero looks different from an eight. It's contemporary. Comes in lots of styles and weights. The LaTeX plex package supports it. Plex has all the Unicode characters I'v tried using from Emacs. It's open-source. Mark Senn, Senior Software Engineer, Engineering Computer Network, Purdue University -mark From mark at purdue.edu Wed Sep 18 08:17:14 2019 From: mark at purdue.edu (Mark Senn) Date: Wed, 18 Sep 2019 11:17:14 -0400 Subject: [Purdue-pm] Emacs editor crash course Message-ID: <27487.1568819834@pier.ecn.purdue.edu> The Purdue Linux Users Group is giving a "Emacs crash course" on Thursday, September 19th from 6--7pm in REC 226. The talk will be about the basics of using the Emacs text editor [1]. The REC (Recitation) building is on Oval Drive surrounding the Memorial Mall---see campus map [2]---it is not far from the intersection of State and Marsteller. (I used the vi editor until the late 1970s then switched to Emacs and have never looked back. I use Emacs on Linux for all editing (except Mathematica [3] notebooks) and reading/sending/etc. of plain text email messages. Emacs also runs on Windows, MacOS, and other operating systems. It is very programmable.) [1] https://www.gnu.org/software/emacs/ [2] https://www.purdue.edu/campus_map/ [3] https://www.wolfram.com/mathematica/ -mark From mark at purdue.edu Sun Sep 22 17:19:34 2019 From: mark at purdue.edu (Mark Senn) Date: Sun, 22 Sep 2019 20:19:34 -0400 Subject: [Purdue-pm] Perl Weekly Challenge - 026 Message-ID: <16403.1569197974@pier.ecn.purdue.edu> My blog entries with my solutions are in https://engineering.purdue.edu/~mark/pwc-026-1.pdf Four different ways to count the number of letters in one string that occur in another. The different solutions are o array-based o cross-product based o hash-based o set-based https://engineering.purdue.edu/~mark/pwc-026-2.pdf Computing mean angles of a given list of angles in degrees. Perl 6 apparently does math using numerical approximations instead of symbolically like Mathematica. I suspect Mathematica would compute exactly the right answers. It would be nice if the Perl developers would update Perl to have the technology that Mathematica has had for over 30 years. (That would be a lot of work to do correctly for the general case.) -mark From jacoby.david at gmail.com Thu Sep 26 10:10:06 2019 From: jacoby.david at gmail.com (Dave Jacoby) Date: Thu, 26 Sep 2019 13:10:06 -0400 Subject: [Purdue-pm] function parameter order question Message-ID: If you have a function that's going to read a file and return the output, and perhaps trigger special behavior if no permissions or file doesn't exist or something, how would you handle parameters? What I am engaging right now looks like this. read_this_file( $special , $output, $input ); Where $output is an arrayref. What I think is a better way of doing this is $output = read_this_file( $input , $special ); With the signatures feature in more recent Perls, you can set the signature like sub read_this_file ( $input , $special = 1 ) { ... } so that it defaults to the wanted behavior, or reverse it or not. Of course, with old syntax, you could also do it. sub read_this_file { my $file = shift; my $special = shift; $special //= 1; ... } So it's more the question of param syntax than function header syntax. Do any of you have strong behavior? -- Dave Jacoby jacoby.david at gmail.com I deal with my software the way I treat my eldritch abomination: It's not human, it's not even alive in the natural sense. It's nightmare-born and nightmare-shaped, and nightmares don't die easy. -- @yenzie -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at purdue.edu Thu Sep 26 11:30:05 2019 From: mark at purdue.edu (Mark Senn) Date: Thu, 26 Sep 2019 14:30:05 -0400 Subject: [Purdue-pm] function parameter order question In-Reply-To: References: Message-ID: <24648.1569522605@pier.ecn.purdue.edu> Dave Jacoby wrote: | If you have a function that's going to read a file and return the output, | and perhaps trigger special behavior if no permissions or file doesn't | exist or something, how would you handle parameters? | | What I am engaging right now looks like this. | | read_this_file( $special , $output, $input ); | | Where $output is an arrayref. | | What I think is a better way of doing this is | | $output = read_this_file( $input , $special ); | | With the signatures feature in more recent Perls, you can set the signature | like | | sub read_this_file ( $input , $special = 1 ) { ... } | | so that it defaults to the wanted behavior, or reverse it or not. Of | course, with old syntax, you could also do it. | | sub read_this_file { | my $file = shift; | my $special = shift; | $special //= 1; | ... | } | | So it's more the question of param syntax than function header syntax. | | Do any of you have strong behavior? OF THE CHOICES ABOVE Of the choices above I would do $output = read_this_file($input, $special); If I WERE WRITING THE CODE FROM SCRATCH Because I list arguments in temporal order I would list $input before $output if both were arguments. When programming I like to handle error conditions right away so I don't have to worry about them later in the program. If I were writing code from scratch to do this I'd probably do if ($special = ReadFile($fn, $output)) { # (I always use $fn as an abbreviation for "file name".) # Handle whatever special is complaining about # so I don't have to think about it anymore. } # rest of code goes here I don't like using "_" in names. Perl 6 allows "-", just like COBOL, I think that's much better than "_". I usually use camel case, in Perl 5 for my sub names. In this example the "R" and "F" are the camel's humps because they're higher than the surrounding characters. If forced to use $special as an argument I would put it last. $output = ReadFile($fn, $special) (In Wolfram Language where all the system functions are in camel case I use all lowercase for my functions.) -mark From mark at purdue.edu Sun Sep 29 19:27:54 2019 From: mark at purdue.edu (Mark Senn) Date: Sun, 29 Sep 2019 22:27:54 -0400 Subject: [Purdue-pm] KLAF data in Mathematica Message-ID: <15304.1569810474@pier.ecn.purdue.edu> Thought people might be interested in how to get KLAF airport data, and Lafayette city data for temperatures in Mathematica. To load the available data for KLAF from 1800 through 2018 just type data = AirTemperatureData["KLAF", {{1800, 1, 1}, {2018, 12, 31}, "Day"}]; That makes Mathematica contact Wolfram Research's server to get their curated data. Wolfram Research has a very wide and deep collection of data. Purdue has a site license for Mathematica. Wolfram Research calls Mathematica "The world's definitive system for modern technical computing". I couldn't agree more. I use Perl 6 for systems programming and general programming and Mathematica for math, calculus, physics, engineering, etc. stuff that Perl 6 can't do conveniently or precisely. The Mathematica notebook source for an example of getting data for the airport, for Lafayette, and plotting the data is at engineering.purdue.edu/~mark/klaf.nb A PDF file of the Mathematica notebook is at engineering.purdue.edu/~mark/klaf.pdf -mark