frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Are Arrays Functions?

https://futhark-lang.org/blog/2026-01-16-are-arrays-functions.html
33•todsacerdoti•1d ago

Comments

SanjayMehta•1h ago
Everything is a function. Next question?
nomel•1h ago
For the downvoters, I think giving examples of what's NOT a function would start an interesting conversation, especially if you don't know how it could possibly be interesting!
winwang•58m ago
I think it depends on what you mean by "is a function". You can think of a constant, `x` as `x_: () -> {x}` (i.e. everything can be indirected). It could be argued that this is "philosophically" "useful" since getting (using) the value of `x`, even as an actual constant, requires at the least loading it as an immediate into the ALU (or whatever execution unit).

Even non-functional relations can be turned into functions (domain has to change). Like a circle, which is not a function of the x-axis, can be parameterized by an angle theta (... `0 <= theta < 2pi`)

whateveracct•55m ago
I think in this context, it is function as in a lambda in LC.

The answer is pretty much, yes, everything can be a function. e.g. A KV Map can be a function "K -> Maybe V"

P.S. If this style of thinking appeals to you, go read Algebra Driven Design! https://leanpub.com/algebra-driven-design

Zambyte•54m ago
Closures and fexprs
jxf•49m ago
In the mathematical sense, all functions are relations, but not all relations are functions.
magicalhippo•22m ago
For me, a x86 interrupt service routine that services a hardware interrupt[1] doesn't strike me as something I'd consider a function. It shouldn't return a value, and it typically has side effects. So why is it a function?

I mean trivially you could say it's a function from (entire machine state) to (entire machine state), but typically we ignore the trivial solution because it's not interesting.

[1]: https://alex.dzyoba.com/blog/os-interrupts/

tombert•1h ago
I remember I got a little confused when I was first learning TLA+, because what you normally call "functions" are "operators" [1], and what you'd normally call "maps" or "lists" are called "functions".

It was odd to me, because it hadn't really occurred to me before that, given infinite memory (and within a mathematical framework), there's fundamentally not necessarily a difference between a "list" and a "function". With pure functions, you could in "theoretical-land", replace any "function" with an array, where the "argument" is replaced with an index.

And it makes sense to me now; TLA+ functions can be defined like maps or lists, but they can also be defined in terms of operations to create the values in the function. For example, you could define the first N factorials like

    Fact == <<1, 2, 6, 24, 120>> 
or like this:

    Fact[n \in Nat] ==
        IF n = 0 THEN 1
        ELSE n * Fact[n - 1]


in both cases, if you wanted to get the factorial of 5, you'd call Fact[5], and that's on purpose because ultimately from TLA+'s perspective they are equivalent.

[1] At least sort of; they superficially look like functions but they're closer to hygienic macros.

shevy-java•47m ago
> Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers.

> I found this to be a hilariously obtuse and unnecessarily formalist description of a common data structure.

Well it is haskell. Try to understand what a monad is. Haskell loves complexity. That also taps right into the documentation.

> I look at this description and think that it is actually a wonderful definition of the essence of arrays!

I much prefer simplicity. Including in documentation.

I do not think that description is useful.

To me, Arrays are about storing data. But functions can also do that, so I also would not say the description is completely incorrect either.

> who can say that it is not actually a far better piece of documentation than some more prosaic description might have been?

I can say that. The documentation does not seem to be good, in my opinion. Once you reach this conclusion, it is easy to say too. But this is speculative because ... what is a "more prosaic description"? There can be many ways to make a worse documentation too. But, also, better documentation.

> To a language designer, the correspondence between arrays and functions (for it does exist, independent of whether you think it is a useful way to document them) is alluring, for one of the best ways to improve a language is to make it smaller.

I agree that there is a correspondence. I disagree that Haskell's documentation is good here.

> currying/uncurrying is equivalent to unflattening/flattening an array

So, there are some similarities between arrays and functions. I do not think this means that both are equivalent to one another.

> would like to see what it would be like for a language to fully exploit the array-function correspondence.

Does Haskell succeed in explaining what a Monad is? If not, then it failed there. What if it also fails in other areas with regards to documentation?

I think you need to compare Haskell to other languages, C or Python. I don't know if C does a better job with regards to its documentation; or C++. But I think Python does a better job than the other languages. So that is a comparison that should work.

lukebitts•38m ago
Some people really do look at a painting and see only brush strokes huh
stackghost•47m ago
It makes sense to consider an array as a function with the index as its input argument and the element its output, i.e. f(x) = A[x]... but I don't see the practical benefit of considering things from this perspective.

When I'm writing code and need to reach for an array-like data structure, the conceptual correspondence to a function is not even remotely on my radar. I'm considering algorithmic complexity of reads vs writes, managed vs unmanaged collections, allocation, etc.

I guess this is one of those things that's of primary interest to language designers?

tialaramex•15m ago
Well for example this insight explains Memoization

https://en.wikipedia.org/wiki/Memoization

If you know that Arrays are Functions or equivalently Functions are Arrays, in some sense, then Memoization is obvious. "Oh, yeah, of course" we should just store the answers not recompute them.

This goes both ways, as modern CPUs get faster at arithmetic and yet storage speed doesn't keep up, sometimes rather than use a pre-computed table and eat precious clock cycles waiting for the memory fetch we should just recompute the answer each time we need it.

zaps•40m ago
idk probably?
Nevermark•35m ago
Arrays and structures are functions.

And all three are tuple [input, output] pattern matches, with the special case that in “call/select tuples”, input is always fully defined, with output simply being the consequence of its match.

And with arrays, structures and overloaded functions being unions of tuples to match to. And structure inputs (I.e. fields) being literal inline enumeration values.

And so are generics.

In fact, in functional programming, everything is a pattern match if you consider even enumeration values as a set of comparison functions that return the highly used enumerations true or false, given sibling values.

hahahahhaah•26m ago
Arrays are objects (allocated memory and metadata if you will). The function is what takes the array and an int and returns an item.
hekkle•15m ago
In Object Oriented programming, yes, arrays are objects and the functions are a property of another object that can perform instructions on the data of the Array Object.

Similarly in Lisp, (a list-oriented language) both functions and arrays are lists.

This article however is discussing Haskel, a Functional Language, which means they are both functions.

Jtsummers•7m ago
> Similarly in Lisp, (a list-oriented language) both functions and arrays are lists.

In which Lisp? Try this in Common Lisp and it won't work too well:

  (let ((array (make-array 20)))
    (car array))
What is the car of an array? An array in Lisp (since Lisp 1.5 at least, I haven't read earlier documentation) is an array, and not a list. It does not behave as a list in that you cannot construct it with cons, and you cannot deconstruct it with car or cdr.
thomasahle•18m ago
What about replacing

> Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers.

with

> Haskell provides indexable arrays, which are functions on the domain [0, ..., k-1]?

Or is the domain actually anything "isomorphic to contiguous subsets of the integers"?

bandrami•18m ago
You can consider any vector a function, though it's not always helpful to do so
clhodapp•14m ago
[delayed]

A 26,000-year astronomical monument hidden in plain sight (2019)

https://longnow.org/ideas/the-26000-year-astronomical-monument-hidden-in-plain-sight/
353•mkmk•7h ago•77 comments

Claude Chill: Fix Claude Code's Flickering in Terminal

https://github.com/davidbeesley/claude-chill
68•behnamoh•2h ago•28 comments

California is free of drought for the first time in 25 years

https://www.latimes.com/california/story/2026-01-09/california-has-no-areas-of-dryness-first-time...
244•thnaks•3h ago•110 comments

Instabridge has acquired Nova Launcher

https://novalauncher.com/nova-is-here-to-stay
134•KORraN•7h ago•96 comments

Are Arrays Functions?

https://futhark-lang.org/blog/2026-01-16-are-arrays-functions.html
36•todsacerdoti•1d ago•20 comments

Show HN: Mastra 1.0, open-source JavaScript agent framework from the Gatsby devs

https://github.com/mastra-ai/mastra
82•calcsam•9h ago•36 comments

Provably unmasking malicious behavior through execution traces

https://arxiv.org/abs/2512.13821
23•PaulHoule•3h ago•3 comments

The Unix Pipe Card Game

https://punkx.org/unix-pipe-game/
181•kykeonaut•9h ago•54 comments

I'm addicted to being useful

https://www.seangoedecke.com/addicted-to-being-useful/
498•swah•15h ago•252 comments

Which AI Lies Best? A game theory classic designed by John Nash

https://so-long-sucker.vercel.app/
42•lout332•4h ago•28 comments

Running Claude Code dangerously (safely)

https://blog.emilburzo.com/2026/01/running-claude-code-dangerously-safely/
287•emilburzo•14h ago•233 comments

Who Owns Rudolph's Nose?

https://creativelawcenter.com/copyright-rudolph-reindeer/
10•ohjeez•1h ago•4 comments

The challenges of soft delete

https://atlas9.dev/blog/soft-delete.html
84•buchanae•4h ago•57 comments

Our approach to age prediction

https://openai.com/index/our-approach-to-age-prediction/
61•pretext•6h ago•121 comments

Unconventional PostgreSQL Optimizations

https://hakibenita.com/postgresql-unconventional-optimizations
265•haki•11h ago•45 comments

Building Robust Helm Charts

https://www.willmunn.xyz/devops/helm/kubernetes/2026/01/17/building-robust-helm-charts.html
26•will_munn•1d ago•0 comments

Catching API regressions with snapshot testing

https://kreya.app/blog/api-snapshot-testing/
6•CommonGuy•5d ago•0 comments

Maintenance: Of Everything, Part One

https://press.stripe.com/maintenance-part-one
71•mitchbob•7h ago•13 comments

Cloudflare zero-day: Accessing any host globally

https://fearsoff.org/research/cloudflare-acme
50•2bluesc•9h ago•12 comments

Lunar Radio Telescope to Unlock Cosmic Mysteries

https://spectrum.ieee.org/lunar-radio-telescope
12•rbanffy•3h ago•1 comments

Dockerhub for Skill.md

https://skillregistry.io/
22•tomaspiaggio12•10h ago•12 comments

IP Addresses Through 2025

https://www.potaroo.net/ispcol/2026-01/addr2025.html
153•petercooper•12h ago•121 comments

Show HN: macOS native DAW with Git branching model

https://www.scratchtrackaudio.com
12•hpen•2h ago•11 comments

The world of Japanese snack bars

https://www.bbc.com/travel/article/20260116-inside-the-secret-world-of-japanese-snack-bars
100•rmason•4h ago•63 comments

Show HN: TopicRadar – Track trending topics across HN, GitHub, ArXiv, and more

https://apify.com/mick-johnson/topic-radar
17•MickolasJae•11h ago•3 comments

Fast Concordance: Instant concordance on a corpus of >1,200 books

https://iafisher.com/concordance/
34•evakhoury•4d ago•3 comments

Nvidia Stock Crash Prediction

https://entropicthoughts.com/nvidia-stock-crash-prediction
350•todsacerdoti•10h ago•295 comments

Danish pension fund divesting US Treasuries

https://www.reuters.com/business/danish-pension-fund-divest-its-us-treasuries-2026-01-20/
620•mythical_39•10h ago•646 comments

Ask HN: Do you have any evidence that agentic coding works?

105•terabytest•13h ago•106 comments

The Zen of Reticulum

https://github.com/markqvist/Reticulum/blob/master/Zen%20of%20Reticulum.md
89•mikece•12h ago•60 comments