luajit does support hashbangs

This commit is contained in:
Felix Van der Jeugt 2021-12-05 12:17:39 +01:00
parent fad5da2e27
commit 0582895825
No known key found for this signature in database
GPG Key ID: 58B209295023754D
14 changed files with 23 additions and 7 deletions

2
clean
View File

@ -4,5 +4,5 @@ part="$2"
day="$(printf '%02d' "$day")"
rm -f ./run ./luac.out
rm -f ./run
rm -f "day${1}/part${2}.hi" "day${1}/part${2}.o"

2
day00/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
io.input(arg[3])
local min, max = math.huge, -math.huge
for i = 1, io.read("*n") do

2
day01/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local count = 0
local previous
for number in io.lines(arg[3]) do

2
day01/part2.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local count = 0
local a, b, c
for line in io.lines(arg[3]) do

2
day02/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local position, depth = 0, 0
for line in io.lines(arg[3]) do
local split = line:find(" ")

2
day02/part2.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local position, depth, aim = 0, 0, 0
for line in io.lines(arg[3]) do
local split = line:find(" ")

2
day03/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local ZERO = string.byte("0", 1)
local ONE = string.byte("1", 1)
local total = 0

2
day03/part2.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
local ZERO = string.byte("0", 1)
local ONE = string.byte("1", 1)
local lines = {}

2
day04/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
function split(text, sep)
local parts = {}
local start = 0

1
day04/part2.lua Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env luajit
require("utils")
local f = io.open(arg[3])

2
day05/part1.lua Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env luajit
function readline()
local x1 = io.read("*n")
io.read(1) -- ","

1
day05/part2.lua Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env luajit
require("utils")
function readline()

View File

@ -5,7 +5,8 @@ part="$2"
day="$(printf '%02d' "$day")"
if test -f "day${day}/part${part}.lua"; then
luajit -v >/dev/null
/usr/bin/env luajit -v >/dev/null
cp "day${day}/part${part}.lua" run
elif test -f "day${day}/part${part}.hs"; then
#stack build
stack ghc -- -O3 "day${day}/part${part}.hs" -o run

5
run
View File

@ -1,5 +0,0 @@
#!/bin/sh
day="$1"
part="$2"
luajit "day${day}/part${part}.lua" "$@"