Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl bby #36

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bin/notNotOdd.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use strict;
use warnings;

my $num;
my $lastDig;

# Need my digit sets
# perl doesn't support sets so have to make them manually
my %odd = (
1 => 1,
3 => 1,
5 => 1,
7 => 1,
9 => 1,
);

if(@ARGV == 0) {
print STDERR "ERROR: No input provided\n";
exit 1;
}
$num = $ARGV[0];

#some debug if anyone needs it in the future
#print "Number " . $num . "\n";

if ($num =~ /(\d)[^\d]*$/) {
$lastDig = int($1);
}

if(exists $odd{$lastDig}){
print "True\n";
exit 0;
}
print "False\n";
1;

23 changes: 22 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import not_odd from "not-odd";
import os from "os"
import { promisify } from 'util';
import { exec as execCallback } from 'child_process';

// Some Async Magic that allows STDOUT to be read after command execution
const exec = promisify(execCallback);
const notOddCS = async function(num) {
var {stdout, stderr} = await exec('./bin/Release/net8.0/notNotOdd ' + num);
if( stdout.includes('odd') ) {
Expand Down Expand Up @@ -48,6 +53,22 @@ export const spareMemory = [



const notNotOdd_pl = async function(num) {

var { error, stdout, stderr} = await exec('perl --version');
if(error){
console.error('Perl Not Installed');
process.exit(1);
}

var { stdout, stderr } = await exec('perl ./bin/notNotOdd.pl ' + num);
if (stdout.includes("True") ) {
return true;
} else {
return false;
}
}

function defNotNotOdd(num) {
//Cosine of the number times Math.PI == 1 is even
return Math.cos(num * Math.PI) === 1;
Expand All @@ -70,7 +91,7 @@ function doesNotNotOddNotOddlyOdd() {

return defNotNotOdd(fib(rand));
}

export const notNotOdd_perl = num => notNotOdd_pl(num);
export const notNotOdd = num => !not_odd(num);
export const notNotNotOdd = num => !notNotOdd(num);
export const notNotNotNotOdd = num => !notNotNotOdd(num);
Expand Down