home.social

#kap — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #kap, aggregated by home.social.

  1. I had a bit of fun, and wrote a blog post where I comment on another blog post that compares R and pandas for some common calculations. I do the same in Kap, to show the differences.

    Obviously Kap is less easy to understand without any prior knowledge. But once you know it, it's quite efficient.

    blog.dhsdevelopments.com/a-lit

    #kap #apl #programming

  2. now that I have a cradle, all I need are some 4' lengths of dowel and I can make a kite for aerial photos. My dowel options are going to be limited to what I can find on this rainy day, most likely sticks of willow or redbud.

    Note to self: kites crash, make a cradle for a dusty old phone and don't use your daily driver.

    if you need me, I'm over at https://www.my-best-kite.com/how-to-make-a-kite.html

    #KAP
  3. I implemented support for the graphics API in the web-based implementation.

    Getting the html components laid out correctly was the thing that took 90% of the time. UI layout was a solved problem in the 90''s. Why is this still such a struggle?

    Anyway, it kinda-sorta works now, so here's an example

    Go ahead and follow the link and click on 'Send' to try it. Everything is client side. No tracking or anything like that.

    #kap #apl #programming

  4. Christian Lawson-Perfect created this absolutely hilarious thing that you have to see. I found it such an incredibly silly idea, in the best possible way. Check it out:

    mathstodon.xyz/@christianp/116

    Anyway, the dataset was fun, so I decided to use it to test scatter plots in Kap. It worked pretty well. I decided to use this data to show how one can work with JSON in Kap. For well-structured JSON, it's actually rather simple.

    youtu.be/-n-vb1nA9s8

    #kap #apl #programming

  5. I wrote another blog post. This time providing some details as to why Kap was kinda bad in the recent video by @code_report.

    Not saying any future tests won't be equally bad, but it's sometimes interesting to know why something happens. At least in one specific case.

    blog.dhsdevelopments.com/kap-p

    #kap #apl #programming

  6. Often when using Kap and I'm working with data coming from REST endpoints, I was getting annoyed that it was difficult to get a nice overview of JSON data in particular, since it doesn't have a nice array-based representation.

    Of course, once you have a grasp of the data, it's easy to transform it, so how do you get that grasp? Well, a tree-based display is useful, so I implemented one. Here's a video showing what it looks like.

    This is the first draft, and I do intend to improve it once it becomes obvious what's needed.

    youtu.be/n3W4rZfLzCo

    #kap #apl #programming

  7. I spent some time improving the Kap UI. Error reporting is a lot better, and I created a short video showing what it looks like.

    youtu.be/Sjcjr-vFjiM

    #kap #apl #programming

  8. Ljubljana is a city of lawyers - so it's no surprise that the earliest known mention of the town and the castle above it involves a certain Rudolphus Advocatus.

    Click and let the kite take you back to the High Middle Ages, to the beginnings of Ljubljana castle and the triple town below it.

    #kiteaerialphotography #KAP #kite #flying #aerial #history #archaeology #medieval #castle #town #Sponheim #Carniola #LjubljanskiGrad #Ljubljana #Slovenia

    kapjasa.si/en/a-castle-in-the-

  9. @jannem @Edent Interestingly enough, these languages originates from Ken Iverson's work on a notation for expression algorithms. This language (called APL) was not initially intended to be used on a computer, but for communication. This made it naturally terse, using symbols rather than words, because it was optimised for a blackboard rather than a terminal.

    He invented some new notation that is used in maths today, including the symbols for floor and ceiling.

    These days, I believe APL and its descendants (including Kap and BQN and others) are the only languages that actually use some variation of these symbols for the floor and ceil operations (in these languages, the symbols and are used.

    So, to divide a by 2 and round down looks like this:

    ⌊a÷2

    One thing Kap does which the other array languages do not is to allow the user to define functions, operators and even new syntax using glyphs that are not used by the language. Some functions in the language are defined in the standard library, and uses this technique.

    #kap #apl #programming

  10. So, today I implemented indexed assignment in Kap. I have for the longest time avoided doing so, because the semantics of the language is immutable, but the syntax itself looks like it mutates an array. After all, that's what pretty much every other language does when faced with this kind of code.

    To illustrate, what do you think the following code will return?

    foo ← 10 20 30
    bar ← foo
    foo[1] ← 50
    bar[1] + foo[1] ⍝ In Kap, the last expression is the return value

    If you guessed 70, you'd be right.

    If you guessed this is because the assignment on the second line makes a copy, you'd be wrong. foo and bar indeed shares a reference to the same object.

    What actually happens is the when you assign to a bracket expression, a new array is created with the updated content, and the value of foo is replaced.

    In other words, it's equivalent to the following expression (which is what you had to write before):

    foo ← {50}⍢(1⊇) foo

    I.e. take element at index 1, replace it with 50 and put it back in the original array, finally assigning that result back to foo.

    It turns out that in practice, you don't have to replace elements at specific locations very often, so explicit syntax for it wasn't really necessary.

    But, as I was typing the new tutorial for the language, I realised that trying to explain structural under (i.e. ) to a beginner is not something I want to do, so I just decided to implement the standard APL notation for this operation.

    Now, to answer the obvious question why I was hesitating to do it earlier: The reason is that this is actually a very costly operation. The entire array is copied every time you replace a single element. It also prevents lazy evaluation, which is pretty bad, since that's what allows Kap to be fast.

    Finally, a beginner user may use this in a loop to initialise an array, which would be a terribly slow.

    I do have some ideas how to make the last case faster though. The idea is to allow an array to be mutable until any of its content is read. We'll see if it becomes necessary to implement this.

    #kap #apl #programming

  11. I've started a new effort to write a tutorial for Kap.

    Do note it's not finished yet

    But if anyone is willing to browse it to see if it's understandable, and even more importantly, interesting, please tell me if I'm on the right track.

    kapdemo.dhsdevelopments.com/tu

    #kap #apl #programming

  12. CW: Spoilers for Advent of Code day 7

    Up until now it feels like the advent of code problems were designed for array languages.

    There are certainly problems that takes multiple lines of code to solve (some of the early problems last year had that property). We'll see what happens in the next few days, but this one was remarkably concise when solved in Kap.

    Here are two separate functions that solve the two parts:

    ∇ solveDay7part1 {
    f ← @.≠ io:read "part07.txt"
    +/ ∊ (1↓f) ∧ ¯1↓ { (⍺>⍵) ∨ ∨/ ¯1 1 ⌽¨ ⊂⍺∧⍵ }\ f
    }

    ∇ solveDay7part2 {
    +/ { (⍺×~⍵) + +/ ¯1 1 ⌽¨ ⊂⍺×⍵ }/ @.≠ io:read "part07.txt"
    }

    Part 2 was even shorter than part 1.

    In both problems, the general approach is the same: Iterate over the rows, and update the correct state based on the locations of the splitters.

    The second problem keeps track of the number of ways in which a certain cell can be reached, which means that the location of a beam is no longer just a boolean value, but a number indicating the number of ways in which this position can be reached. The result is then simply the sum of all beam values in the last row.

    I also note that so far, most of the problems have not had weird edge cases. For example, in today's problem there were no cases of two splitters next to each other, or were there any splitters at the beginning or end of a line. If that had been the case, the solutions would be a bit more complicated.

    #adventofcode #programming #kap #apl

  13. CW: Spoilers for Advent of Code day 6

    Day 6 was interesting. In part 2, you have to parse text vertically, in a way where array languages really shines (transposition of 2-dimensional data is just a single character).

    The solution I came up with is... ok... I guess? It feels it should be possible to do it much more concisely than I did it, and I've seen solutions in other languages that are on the same order of magnitude in size compared to the Kap solution, which is not something you see very often.

    In particular, I saw an amazing Ruby solution that puts mine to shame, and I say that even though I don't even know much Ruby and never really liked it that much.

    I am kind of happy with the way I implemented the operation selection. I take advantage of the case function (docs). It computes both the sums and the multiplications, and then uses case to pick the correct set of results.

    Kap can do this without computing the double computing results, since the results of the sums are lazy, and the individual results will only be computed when the result is read.

    codeberg.org/loke/advent-of-co

    #adventofcode #programming #kap #apl

  14. CW: Spoiler for Advent of Code day 3

    We're still in the easy part of advent of code. I have still been able to solve them in a single line of code per problem.

    For part 2, I used the reduction operator for iteration. A more classic APL solution would probably use in order to conserve memory (even though in this case, you only iterate 12 times anyway, so it doesn't matter).

    In general, using / for iteration in Kap is less ugly than in APL, since Kap has lazy evaluation, so in most cases you wouldn't materialise the array you're reducing over anyway, so it's often a simpler solution than to try to bend the power operator to do what you want, which is not always obvious. At least that's my preference.

    codeberg.org/loke/advent-of-co

    #adventofcode #programming #kap #apl

  15. CW: Spolers for Advent of Code day 2

    I was at work when I first read the problem. I also misread the problem such that I thought it was actually the problem as described in part 2.

    So, I spent some time thinking about a way to solve it efficiently, since I assumed there were going to be huge ranges of numbers, and I needed a way to quickly filter out values.

    When I finally took a look at the actual data, I realised that it was possible to brute-force, and the solution turned out to be much simpler.

    ∇ loadData {
    ,/ {…/⍎¨⍵}¨ (@-≠)⍛⊂¨ (@,≠)⍛⊂ ↑ io:read "part02.txt"
    }

    ∇ solveDay2Part1 {
    +/ { a←10⊤⍵ ⋄ ⍵ × ∧/=⌿ 2 ¯1 ⍴ a,(2|≢a)⍴100 }¨ loadData 0
    }

    ∇ solveDay2Part2 {
    +/ { a←10⊤⍵ ⋄ d←1,math:divisors ≢a ⋄ ⍵ × 1∊{ 1=≢∪ ¯1 ⍵ ⍴ a }¨ d }¨ (10≤)⍛/ loadData 0
    }

    #adventofcode #programming #kap #apl

  16. CW: Spoilers for Advent of Code day 1

    These are my solutions for day 1. I always enjoy it when I can write the entire solution in a single line of code.

    For part 1, the majority of the code is in the conversion of the input data. In part 2, the conversion code is exactly the same, but the solution is a bit longer.

    The input conversion converts a string "L10" to -10, and "R10" to 10. Part 1 in then simply a matter of performing a sum scan over the values, take the results mod 100 and count how many zeroes there are.

    Part 2 was a bit more annoying. I solved it by creating a sequence of all numbers that is processed, meaning that L5 R2 becomes 50 49 48 47 46 45 46 47. I then take the values mod 100 and count the number of zeroes, exactly like the previous solution.

    ∇ solveDay1part1 {
    +/0=100|+\50 , (¯1+2×@L=↑)«×»(⍎↓)¨ io:read "part01.txt"
    }

    ∇ solveDay1part2 {
    +/0=100| {⍺,(↑⌽⍺)+(×⍵)×1+⍳|⍵}/ 50 , (¯1+2×@L=↑)«×»(⍎↓)¨ io:read "part01.txt"
    }

    #adventofcode #programming #kap #apl

  17. For a while I've had this idea that often you want to create a simple form for displaying and inputting values. You want to do that without having to design a full on application, and you also don't really care about what it looks like.

    Back in the day, there were tools like forms designers in databases like dbase, or people used visual basic to whip together a quick UI.

    I've also seen some creations in excel that are both terrying and wildly impressive at the same time.

    I'm not sure what people use these days (other than excel, which is still going strong), but I like to use Kap when working with data in different forms.

    Array languages are really convenient when manipulating large datasets, but sometimes I just want to bring up a quick form, to simplify various common operations.

    I was inspired by the SCREEN SECTION in COBOL, which allows you to declare input and output fields in a grid, and then read/write the data in it. So that was my thinking when I started working on the forms module for Kap.

    It's nowhere near usable yet, but I can at least bring up a window and read the data, which is enough to start experimenting with how things like this can be used. I created a short screen recording showing how it works.

    youtube.com/watch?v=rAMtwDvPrvo

    The implementation is platform-agnostic, and I intend to add both HTML-based renderer and a text-based one when used on a terminal.

    #kap #apl #programming

  18. A link to the following code was shared on my feed. The actual post was about something else, but the anagrams program was interesting. It prints the longest anagrams that was found in the dict file.

    Obviously I wanted to write a version in Kap (and yes, I'm posting this to my feed, because unless I try to only annoy people who has previously indicated that they want to be annoyed by me (possibly by following me) 🙂 ).

    Here's the implementation in factor: github.com/factor/factor/blob/

    And here is my version in Kap, that prints all different forms of the 10 largest words (i.e. the words with the most anagrams, the biggest having 15 of them.

    I just found it a fun exercise to write it in a single line of code.

    10 ↑ (⍒≢¨)⍛⊇ (=∧¨)⍛⫇ ∪ unicode:toLower¨ io:read "/usr/share/dict/words"

    This tells us that the winner is:

    "acers" "acres" "arces" "cares" "carse" "caser" "ceras" "cesar" "cresa" "escar" "races" "sacre" "scare" "scrae" "serac"

    I have no idea what most of those words mean.

    #kap #apl #programming

  19. A relaxing afternoon read about the most amazing festival on the Island at the End of Summer: 13th Creative Days of Faust Vrančić!

    It was, yet again, unforgettable, crazy, fun, beautiful, full of love, and *wayyyy* too short. Thank you for having us! 😉

    kapjasa.si/en/prvic-forever/

    #kite #kites #kitefestival #festival #creativity #kiteaerialphotography #KAP #party #concert #culture #exhibition #Prvić #Dalmatia #Croatia

  20. As we are getting closer to Advent of Code, and as a programming language designer, I obviously want to promote my particular dialect of APL.

    So what should I do to encourage people to rry it for Advent of Code? For myself, others trying it will help me learn what can be improved, both for the documentation as well as the implementation itself.

    Should I offer a prize?

    kapdemo.dhsdevelopments.com/

    #kap #programming

  21. A special kite aerial photography exhibition "Les yeux du vent" ("Eyes of the wind") was held during the fantastic Festival International de Cerfs-Volants de Dieppe 2025 - and the jury selected three of our photos to be included! :-)

    Read all about it here:
    kapjasa.si/en/eyes-of-the-wind

    #kiteaerialphotography #KAP #kite #flying #aerial #art #photography #exhibition #dieppe #normandie #france #teamslovenia

  22. So, in Kap there is currently three ways to display rational numbers (chosen using the interactive command ]ratmode). These are:

    • normal -- The numerator and denominator are displayed separated by a slash: 12/11
    • fancy -- This is the same as the above, except it uses the faction slash symbol, which makes them render nicely on platforms that supports it (such as the web): 12⁄11
    • decimal -- This uses a decimal representation with an r suffix, prefixed with if the conversion to decimal cannot be done exactly ≈1.09090909r

    I'm consider a variation of normal and fancy that would break out to the integer part: 1+1⁄11.

    Note, I had to display the versions with fraction slash outside of a code block, since when enclosing them using backquotes, they render the same way as they do in the native gui. This doesn't happen in the web-based version of the interpreter though, so you can try it there if you want.

    The question is, which mode should be default when starting the interpreter (and remember that the native GUI version does not render fraction slash very well. It looks very similar to just a regular slash, just wider).

    #kap #apl #programming

  23. A medieval "forštat" - vorstadt, faubourg - is a liminal quarter: not in the (walled) city proper, not a suburb either. We flew above the oldest and perhaps the best preserved forštat quarter of Ljubljana, Saint Peter's.

    Bonus: the most iconic bridge we have! 😉

    kapjasa.si/en/saint-peters-vor

    #kiteaerialphotography #kite #KAP #flying #aerial #city #medieval #forštat #vorstadt #quarter #bridge #SaintPeters #dragons #dragonbridge #zmajskimost #šentpeter $trubarjeva #petkovškovo #Slovenia #Ljubljana

  24. @linux_mclinuxface A followup. For very large, complex input, the streaming solution is vastly more efficient.

    The following expression generates a 4-dimensional array of dimensions 100×100×100×10, i.e. 10 million elements. Each element is a nested array containing 4 integers: the coordinates to that cell.

    Due to inefficiencies in the current alpha version of the serialisation format, this array serialises to a 124 MB data stream.

    The valkey:setobj function writes this array in serialised form to valkey. We can see that the entire operation takes 0.603 seconds (note that the actual numbers varies quite a bit, but this is a close enough average).

        time:runtime { c valkey:setobj "largeobj2" ⍮ ⍳100 100 100 10 }
    Total time: 0.603

    Now, let's do the same, but explicitly encode the array to a byte array and store it using valkey:set. This is pretty much identical to what happened before the blocked streaming was implemented:

        time:runtime { c valkey:set "largeobj2" ⍮ encoder:encode ⍳100 100 100 10 }
    Total time: 0.659

    So in general, the streaming solution tends to be faster. That said, if I take the absolute best times I got for both, they were remarkably close (within 1 or 2 ms of 0.534, if I remember correctly)

    #kap #programming #valkey

  25. A discussion on the BQN Matrix channel about Project Euler number 21 led me to think that the divisors function in Kap would be useful for this.

    Turns out I was right. The solution turned out to be pretty simple, once one realises that an amicable number is one where if you take the sum of the divisors twice, you get back to the original number and the sum of the divisors is not the same as the number itself.

    The following Kap code solves the problem by taking advantage of this:

    +/ ⍸ ≠/ (⊂↑)«=¨»(1↓) (1+ +/¨math:divisors ⊣)\ (⍳10000) 0 0

    Run in browser

    The code should be reasonably easy to understand for anyone with some APL experience, but I'll be happy to explain in more details if anyone is interested.

    The scan operator is being abused a bit by turning it into a preserving version of repeat. I think if there was a collecting version of repeat, that would be a nicer way to do it.

    #kap #apl #programmming #maths

  26. We flew our kite above a hillfort of St.Mary of the Snows on Podgorje karst, Slovenia.

    This story starts with Neolithic dentirstry, goes through Bronze and Iron Age, and ends with a cute little church. Enjoy! ;-)

    kapjasa.si/en/mothers-and-godd

    #kiteaerialphotography #KAP #history #archaeology #hollfort #church #karst #neolithic #bronzeage #ironage #karst #kras #podgorje #kaštelir #kite #kiteflying #aerial #flying #Slovenia

  27. A veritable puff pastry of history was created on this hill above Bloke plateau, Slovenia.
    From the Iron Age, the Romans, the Migration period, the Middle Ages, the Ottoman incursions, and on to the present day: the church of St Urh on Nadliški hill is just the top of so many layers of history ...

    kapjasa.si/en/layers-of-histor

    #kiteaerialphotography #kite #KAP #aerial #history #archaeology #church #hillfort #Romans #castle #fort #bloškaplanota #nadliškivrh #bloke #Slovenia

  28. Estoy jubilado, soy curioso y tengo un interés casi universal por la vida, la tecnología y el arte. Me gusta tener ideas, hacer cosas y aprender como funcionan las cosas.

    En esta red social busco personas interesadas en los mismos temas que yo para poder intercambiar conocimiento, experiencias y charlar de esos temas.

    Tengo un blog denominado "Lo Marraco" en:

    robertopla.net/blog/

    Mis intereses son bastante diversos:
    #urbansketching #estilograficas #caligrafia #python #encuadernacion #linux #legotechnic #video ...

    Y algunos otros, más o menos relacionados:

    #make #arduino #bujo #collage #lettering #scrapbooking #cometas #kap #fotografia #tic #3dprinting #estereofotografia #wordpress #blogging

    #presentacion

  29. A fascinating prehistoric settlement of Debela griža near Volčji grad, Kras, Slovenia, as seen from a kite.

    This double-walled enclosure dates back to the Bronze age (around 1200 BC).

    Kite aerial panorama made from photos shot with Ricoh GR on a Rokker kite.

    #kiteaerialphotography #KAP #kite #kiteflying #aerial #photography #prehistoric #settlement #BronzeAge #IronAge #history #archaeology #DebelaGriža #VolčjiGrad #kras #enclosure #hillfort #walls #karst #Ricoh #RicohGR #Rokker #Slovenia