Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Ranchonyx pattern matching a list.
don't know enough yet, but _ is "any value" and "::" is "join elements to form a list out of them". -
It would be valuable if more programmers began to think of list-like types as being divided into "head" and "tail" elements.
ALMOST all tutorials and material that I've seen teach about sequential data structures, without going in depth beyond standard manipulation and syntax.
I learned to treat lists as their component head/tail from Erlang and I recommend it (for learning both that, and pattern matching), to anyone who will listen. -
@Wisecrack i agree, still just learning that thinking, but what makes me dislike/nervous about it is the ever-implied recursion, and its limit.
especially in languages where recursive functions are the official right way to do things
!rant
...i realized i can actually pattern-match like this (as in, sequence of elements (including "whatever") instead of just head::rest in F#...
...from watching a talk about prolog.
like "wait... prolog can do this when pattern-matching? that seems very useful. i think i tried to do that in F# but it didn't work, which seems stupid... I'm gonna go try it again".
and sure enough =D
i think i really am gonna like F# if i find the time and resolve to break through how its different mode of thinking stretches my brain in ways it hasn't been stretched for a long time =D
rant
feels nice man