11
votes
Tips for golfing in APL
Use ⊥ to combine multiplication with addition
(a×b)+C -> a⊥b,C
(C)+a×b -> a⊥b,C
(a×b)-C -> a⊥b,-C
Assumptions:
...
10
votes
Tips for golfing in APL
Complex numbers
Often overlooked, they present wonderful opportunities to shorten expressions dealing with grids, mazes, fractals, or geometry.
...
10
votes
Tips for golfing in APL
Tricks for dealing with / and ⌿ in trains
When using trains you may want to use reductions f/...
10
votes
What valence does this APL train have?
Haskell, 61 bytes
f t=[and$zipWith(/=)t$[2|even$length t]++cycle[x,0]|x<-[2,0]]
Try it online!
Takes a list of: 0 for monad,...
10
votes
9
votes
Official Dyalog APL 2016 Year Game
Hexagony, 888 bytes
Okay, first some ground rules for Hexagony, in case anyone wants to beat this:
I'm interpreting "snippet" as a linear piece of code that can be dumped into any sufficiently large ...
9
votes
Take that frown and turn it around
Python 3, 105 bytes
lambda s:":⊢⍡⊣:▷⍢◁:⋆⍣⋆:∘⍤∘:○⍥○:≀⍨≀:∧⍩∨:".split(s)[1][:3-len(s)]
Try it online!
9
votes
Take that frown and turn it around
JavaScript (ES6), 108 107 bytes
s=>(S="⊢▷⋆∘○≀∧⍡⍢⍣⍤⍥⍨⍩⊣◁⋆∘○≀∨")[S.search(s[1]||s)+7]+(s[1]?'':':')
Demo
...
9
votes
What have we got?
JavaScript (ES6), 145 ... 138 136 bytes
Returns \$0\$ for dyadic dops, \$1\$ for monadic dops, \$2\$ for dfns and \$3\$ for other.
...
9
votes
Ken Iverson’s Favourite APL Expression?
APL (Dyalog Unicode), 7 bytes
+∘⌽⍨0,⊢
Try it online!
Prepend a zero, and add the mirrored array:
...
9
votes
Ken Iverson’s Favourite APL Expression?
Python 2, 34 bytes
lambda l:map(sum,zip(l+[0],[0]+l))
Try it online!
37 bytes
lambda l:map(int.__add__,l+[0],[0]+l)
Try it ...
8
votes
Accepted
8
votes
Official Dyalog APL 2016 Year Game
J, 1041 ... 838 bytes
981 961 952 860 859
I got a little lazy to the end, but it should be more fixed than less. I don't think I'll ever overtake Hexagony, but you never know! beating hexagony! ...
8
votes
Clearly parenthesize APL trains
APL (Dyalog Classic), 71 68 65 63 bytes
0{⍵≡⍕⍵:⍵⋄⍬≡⍵:'⍬'⋄1=≢⍵:⍺∇⊃⍵⋄3≥≢⍵:⍺⌽')(',⍣⍺∊1∇¨⍵⋄⍺∇¯3(↓,∘⊂1∇↑)⍵}⍎
Try it online!
The characters I chose for I/O are ...
8
votes
Implement 1-dimensional version of Multi-Take
APL (Dyalog Unicode), 58 50 bytes
{{2⊃{⍵[⍒⍴¨⍵]}(⍺,⍵)A⍺(⍵,⍺↓⍨≢A)}/((⌈/,⌊/)0,⍵)↑¨⊂A←⎕}
Try it online!
What better way to implement this than in APL itself? That ...
8
votes
What valence does this APL train have?
APL (Dyalog Unicode), 59 bytes (SBCS)
Anonymous tacit prefix function. Returns [] if invalid, [[]] if dyadic, ...
8
votes
Ken Iverson’s Favourite APL Expression?
Jelly, 2 bytes
Ż+
A monadic Link accepting a list of integers which yields a list of integers.
Try it online!
How?
Pretty simple in Jelly to go with the method ...
8
votes
Floor of complex number
J, 32 31 26 bytes
j.&<.+((1<:+)*0j1^<)&(1|])
Try it online!
-5 thanks to Razetime for pointing out I could take real and imag parts as left and ...
8
votes
Evaluation order of an APL n-train
J, 14 bytes
[:\:0 _2#:i.@-
Try it online!
Alternative solution that makes use of divmod with negative divisor.
How it works
Example using ...
7
votes
Tips for golfing in APL
Indexing modulo vector length
⊃i⌽a is often shorter than the naive ⊃a[(≢a)|i] or a⊃⍨i|⍨≢a (...
7
votes
Tips for golfing in APL
Generate A001057, A130472, and many variations
A001057 is a simple sequence of alternating integers, starting with 0, 1, -1, 2, -2, 3, -3, .... A130472 is its ...
7
votes
Official Dyalog APL 2016 Year Game
Dyalog APL (This is a joke, please don't submit), 25,957 bytes.
2016⊢≢⍬
2016⊢(⊢+≢)≢⍬
2016⊢(⊢+≢)(⊢+≢)≢⍬
...
Yeah, this is a joke entry, we need an APL solution, ...
7
votes
Official Dyalog APL 2016 Year Game
JavaScript (ES7), 836 bytes
Everything should work in any browser except 81, 88, and 97, which use the new ** operator.
Mostly everything here was done by hand. I'...
7
votes
Official Dyalog APL 2016 Year Game
JavaScript, 1021 bytes
Fixed and saved two bytes thanks to Charlie Wynn and ETHProductions.
...
7
votes
Ken Iverson’s Favourite APL Expression?
05AB1E, 5 4 bytes
0šÂ+
Try it online or verify all test cases.
Or alternatively:
0š+Ć
-1 byte thanks to @ovs.
Try it online or ...
7
votes
Ken Iverson’s Favourite APL Expression?
Factor, 27 bytes
[ 0 suffix dup reverse v+ ]
Try it online!
7
votes
Floor of complex number
R, 55 bytes
function(x,y=x%%1)(x+(sum(y)>1)*c(z<-diff(y)<0,!z))%/%1
Try it online!
Straightforward implementation of McDonnell's function.
R, 71 bytes
<...
6
votes
What have we got?
Jelly, 50 48 46 45 bytes
Ỵµṣ”'m2Kṣ”#Ḣ)KµċⱮƤØ{IF©<-oµ⁾waż¤ẇ€‘Ḅ«5×®¬Ḅ⁼1¤
A monadic Link accepting a list of characters which yields:
...
6
votes
Implement 1-dimensional version of Multi-Take
JavaScript (ES6), 103 97 96 bytes
Expects (A)(N).
...
6
votes
Ken Iverson’s Favourite APL Expression?
Haskell, 26 25 bytes
o l=zipWith(+)(0:l)l++[1]
Try it online!
Saved 1 thanks to @ovs
New approach, it essentially do this:
0[1,2,1] +
[1,2,1] =
[1,3,3] + 1
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-golf × 15apl × 15
parsing × 5
sequence × 3
array × 3
string × 2
classification × 2
math × 1
ascii-art × 1
decision-problem × 1
arithmetic × 1
integer × 1
tips × 1
restricted-source × 1
random × 1
permutations × 1
balanced-string × 1
unicode × 1
open-ended-function × 1
programming-puzzle × 1
complex-numbers × 1
statistics × 1
expression-building × 1