« first day (725 days earlier)      last day (1922 days later) » 

3:30 AM
@ngn How do you do IO in K4?
 
4:13 AM
@ngn Wow! |+\` is brilliant. That makes this the full solution: +/(~2!)#*:'{4000001>x@1}(|+)\1 1`
Is there any way to clean up the rest? I especially don't like putting the constant 4000001 instead of 4000000, but there seems to be no greater-equal (>=) operator in K.
My backslashes are getting eaten by the code formatter and I ran out of edits trying to fix it.
 
4:25 AM
The implementation of Euclid's greatest common factor algorithm at http://kparc.com/z/fun.k is great. Here's a tacit gcf routine based on it: gcf:*|*|(*)(|!\)\
Example usage: gcf 55 60. I don't get why I have to enclose the third star in parenthesis. Originally I had {*x} instead of (*). {*x} is clearer (maybe?) but (*) is shorter.
I seem to have fixed my code formatting issues here. I now use two backticks before code and two backticks after it.
The example code for Conway's Game of Life at kparc.com/z/fun.k doesn't work in oK. The error is: invalid arguments to ': [-1 +/ (valence 1), (0 1 1 0...
 
4:53 AM
The Collatz one is amazing too.
Each of them is so compact! The meaning doesn't become clear until I study it carefully. Like a Zen koan.
 
 
6 hours later…
ngn
10:29 AM
@jordancurve if it's for project euler, this could be the only verb you need: 0:"filename" (and/or 0:`:filename in some versions of k) reads a file and returns a list of lines
0: in this case is not "assignment to 0", but special syntax for a verb
more details on io - in the reference and in the "q for mortals" book (in q syntax)
 
ngn
10:49 AM
i tested - in k4 0:`:filename works and 0:"filename" doesn't
@jordancurve there's no greater-equal but you can use "not less" instead: ~x<y
@jordancurve we've all been bitten many times by the peculiarities of chat markdown...
there's a sandbox room where you can test if you like
@jordancurve that * acts as the left argument to (|!\)\ . if you use a naked *, it will parse as * applied to (!\)\ , applied to etc.; however the parentheses "nominalise" it, i.e. turn in into a noun
hm... i'm not sure oK implemented this correctly
something's not quite right with the parsing of that (*) in oK, but anyway...
you could simplify *|*|{*x}(|!\)\ to *|{*x}(|!\)/
 
ngn
11:46 AM
@jordancurve i've no clue what's going on there. that game of life implementation doesn't work in any version of k known to me. it's also wrong, unless the meanings of some primitive has changed
-1 f': x used to mean "each-prior with initial value -1". could it be that now it's "apply f to a sliding window of 1 before and one after", like dyalog's ⌺3 ("stencil")?
 
12:13 PM
Easy main challenge up for grabs using :
17
Q: Implement the game of life in 3D

Jens RendersThe challenge is to find the shortest implementation of the game of life in 3D (example). These are the rules: Cells (in this case, cubes) with only 1 or less neighbours die, as if by lonliness. If exactly 5 cells surround an empty cell, they breed and fill it. If a cell has 8 or more neighbours...

 
ngn
@ngn oops, i missed a | there
 
 
4 hours later…
3:56 PM
0
Q: In what way is APL made more useful by the distinction between scalars and vectors?

Erik MidtskogenI'm an experienced software engineer beginning to study APL, and in order to get a better feel for the language early on, I would like to understand why the language exposes to the coder the difference between scalars and vectors. As far as I can tell this far into my studies, this only introduc...

 
4:31 PM
@Adám ^ is there any other place where a scalar acts unlike any other rank thing than as an argument to a scalar function?
 
@dzaima Some operators will insist on a scalar operand. E.g. .
 
@Adám right, but that's to be expected, and a built-in may as well require that an argument is a 7-dimensional array and nothing else
 
@dzaima Right. I'm not even sure what he means
 
@Adám exactly, I'm writing a comment
 
@dzaima thanks. I'm celebrating holiday atm.
 
4:41 PM
@Feeds POB...
 
ngn
4:55 PM
@dzaima stranding - what's the depth of (0)(1)?
 
5:07 PM
@ngn i don't understand why everyone thinks that strands of primitives is something special :|
 
no primitives in there...
 
@EriktheOutgolfer sorry, i call simple scalars primitives
@ngn ≡a a is 1+≡a always, no?
 
ngn
5:21 PM
@dzaima but what is ≡0 if there's no distinction between scalars and vectors?
 
@ngn imo depth is a very strange built-in, considering that 1≡⊂1, but right, depth is another thing that very much depends on simple scalars
 
 
1 hour later…
6:24 PM
any reason APL doesn't have an array creating notation that can create an array of 0, 1, 2+ items in the same, consistent way?
 
@dzaima Apparently the need hasn't been great enough yet. Have you seen
 
@Adám yeah, but (1),1 and ()
@dzaima *vector of 0, 1, 2+ items
 
@dzaima True, the parens are not like JSON/K parens. But (1⋄)≡,1 and how would you specify prototype? E.g. 0⍴⊂'' ⍬.
 
@Adám prototypes suck :|
 
@dzaima By all means, if you have feedback on the notation or an entirely new idea, we're all ears.
@dzaima Are there any notations out there for generalised tensors?
 
6:39 PM
@Adám JSONs [a,b,c], [a], [], though that comma placement is kinda arbitrary
 
@dzaima How do you write 0 3⍴0? ;-)
 
@Adám right, but i'm specifically asking for vectors. higher dimension things are strange :p
 
inb4 "but isn't 0 3⍴0 an array? ;-)"
 
@dzaima Uh, so now you are using the word "arrays" artificially limited meaning of scalars/vectors of scalars/vectors etc.?
 
6:44 PM
@dzaima I really didn't understand what that meant.
 
@Adám replace "array" in that message with "vector"
 
@dzaima edits ping...
 
@EriktheOutgolfer i know, and i hate that
i have a bad habit of editing useless things :p
 
(⍬) and (⍬,1) and (⍬,1,2) etc. seems consistent.
@Feeds Do any langauges that have the concept of an array lack distinction between scalars and arrays?
 
@Adám right, another thing i thought about
 
7:41 PM
 
@dzaima Nothing strange. Parsing from right: 2 then +2 then ∨2 but cannot be monadic.
 
@Adám ah, okay. kind of expected tokenization to die before it gets to parsing
 

« first day (725 days earlier)      last day (1922 days later) »