class Atan2APLFunction : APLFunctionDescriptor {
class Atan2APLFunctionImpl(pos: FunctionInstantiation) : MathCombineAPLFunction(pos, resultType1Arg = ArrayMemberType.LONG) {
override fun combine2Arg(a: APLSingleValue, b: APLSingleValue): APLValue {
return numericRelationOperation(
pos,
a,
b,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load 'tangentstorm/j-kvm/vm' | |
NB. Turn face | |
T =: {{ |:@|.^:x y }} | |
NB. Y rotation | |
Ya =: [: (_1 1 T"_1 ])&.((2 1;0 1)&{) (1 |. ])&.(1&{) | |
Yb =: Ya^:3 :. Ya | |
Y =: Ya :. Yb |
J solution (~0.2s runtime on my machine)
Nats =: '0123456789'&(i. ".@:{ ' ' ,~ [)
Claim =: ,"0/&((+ i.@])/)
claims =. |:@(2 2 $ }.)@Nats;._2 fread 'input'
claimed =. <@,@(1000 #:inv Claim)/"2 claims
echo # overlaps =. (~.@#~ -.@~:) ; claimed NB. Part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n =: 100 | |
z =: 136 240 | |
pos =: 5 + (? n # ,: 10 -~ z) | |
vel =: 5 * 0.5 -~ (? n # ,: 0 0) | |
col =: >: 15 | i. n | |
R =: [: >./ (2 2 -~"1 ($ #: I.@,)#:14 31 31 31 14)&(|.!.0) | |
F =: {{)d | |
pos =: pos + vel | |
vel =: vel * <: +: ((z-3)&> *. 3&<)"1 pos | |
R col (<. pos)} z $ 0 |
require 'viewmat plot'
colorxy =: colorxy_jzplot_
dm =. ,~ 200 NB. dimensions
np =. 50 NB. number of points
ps =. ? np $ ,: dm NB. points
NB. Voronoi tesselation
Dist =: +/"1@(*:@-"1/)
Some J translations of some of the flat array programming techniques discussed in this article series: -
- Part 1: https://saltysylvi.github.io/blog/flat1.html
- Part 2: https://saltysylvi.github.io/blog/flat2.html
Reverse words
s =. 'here are some words'
p =. +/\ 0, 2 ~:/\ ' ' = s
echo s {~ |. \: p
NB. ==> ereh era emos sdrow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cocurrent 'times' | |
dz_times_ =. 24 * *~ mz_times_ =. 60 | |
ot_times_ =. 719469 | |
dur_times_ =. ((100 * 365.25) - 0.75), 365.25, 30.6 | |
off_times_ =. (ot_times_ - 0.25), 0.75, 0.41 | |
T_times_ =. {{ | |
'day sec' =. (0, dz) #: y |
Some horribly hacky Raku code that pretends to be a barely functional logic language
use lib 'lib';
use Logos;
enum < tom sally bob mark floppy book >;
fact :person(sally);
fact :person(mark);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.36; | |
use warnings FATAL => 'all'; | |
use Path::Tiny qw< path >; | |
my $v = qr{ ( [A-Za-z][.:] | [0-9][:] | [^ A-Za-z0-9()] )+ }nx; | |
my $p = qr{ \( ($v \s+ $v)+ \s+ $v \) }nx; | |
my $iter = path('code/aoc')->iterator({ recurse => 1 }); | |
my %seen; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nixlib =. '/usr/local/lib/libraylib.so' | |
winlib =. jpath '~/raylib/lib/raylib.dll' | |
raylib =: IFUNIX {:: winlib;nixlib | |
Uh =: 0 {:: ] f. NB. Unbox head | |
NB. Window-related functions | |
InitWindow =: (raylib,' InitWindow n i i *c') cd ] | |
CloseWindow =: (raylib,' CloseWindow n') cd ] | |
WindowShouldClose =: Uh (raylib,' WindowShouldClose i') cd ] |
NewerOlder