anoma / juvix-stdlib

The Juvix standard library
https://anoma.github.io/juvix-stdlib/
10 stars 1 forks source link

Rename `snoc` to `append` #137

Open heueristik opened 4 hours ago

heueristik commented 4 hours ago

The majority of people won't know what snoc is.

--- 𝒪(𝓃). Append an element.
snoc {A} (list : List A) (elem : A) : List A := list ++ elem :: nil;

Please do the same for all other unusual names

lukaszcz commented 4 hours ago

Actually, isn't list ++ [elem] clearer? Maybe remove snoc altogether?

The problem with append is that in functional languages it is normally a synonym for ++. snoc appears in some functional languages, but indeed it's cryptic for people not already familiar with it.

Alternatively, we could call this appendElement or similar.

lukaszcz commented 4 hours ago

A list of names considered unusual would be helpful.

lukaszcz commented 4 hours ago

A case for not having a separate function for this is that you actually don't want to be doing snoc too much (linear running time).