Elektrine lite

← Feed

@numeredevs@fosstodon.org

2026-07-22 15:22 UTC

@loke@functional.cafe @jwildeboer@social.wildeboer.net I don't want to start a philosophical discussion about that and it's still only a recommendation, but my point was more about this statement: "Any elements that are shorter gets filled in with the fill element, which is 0 by default." An empty list is closely related to an empty set and I do not think that there is a bijection between that and one or more zeros, i.e. yo cannot undo the operation. Therefore I'd consider using NaN or something like "void" as default instead.

Replies (1)

  • @loke@functional.cafe 2026-07-22 16:08

    @numeredevs@fosstodon.org @jwildeboer@social.wildeboer.net oh this is the kinds of discussion I really enjoy, and you're making a good point. The default behaviour comes from APL, which fills will the 'fill value' of the array itself. It's kind of complicated, but generally boils down to either going with 0 or a space, for numeric or character stays respectively. This was important back in the early days of APL which didn't support nested arrays. Now Kap improves on this (in my opinion) by simply having a single full value for functions that need it. This behaviour is similar to what J does. This value is 0 by default, but you can add a specification to the function call that tells the function to use a different fill value. So you could just specify null (or even a special error value which will raise an error when accessed). So adapting your suggestion, Kap should use null or the error value as a default fill value. This is actually a pretty good idea. If this was only for the disclose function (which converts a nested array into an array with one dimension higher) then I'd make this chance right now. The problem is that the fill feature is used in other cases too, for example when taking n elements from an array of size m where n>m. The fact that it fills with 0 is commonly used in various algorithms. If you're interested in the history of the full value in various array languages, there is an aplwiki page for it: http://aplwiki.com/wiki/Fill_element The above page uses the term mix to describe the operation that Kap refers to as disclose.

    Open ##5136247