|
MononcQc posted:if your programming language doesn't have pattern matching it's a dumb language from the past. Why wouldn't it just be a library
|
# ? Aug 5, 2012 18:48 |
|
|
# ? Jun 11, 2024 16:16 |
|
Zizzyx posted:why doesn't that also print butts idgi it matches the first one, so you can have a catchall farther down that only gets called when nothing above it matches
|
# ? Aug 5, 2012 18:57 |
|
Cocoa Crispies posted:if you can't build it yourself lol vapid cutlery posted:Why wouldn't it just be a library It can be. The important thing is that everyone should be using it in that community.
|
# ? Aug 5, 2012 19:20 |
|
MononcQc posted:if your programming language doesn't have pattern matching it's a dumb language from the past.
|
# ? Aug 5, 2012 19:22 |
|
MononcQc posted:as long as you can pattern match on other data types that can be decent. yeah that uses the "===" in ruby which does a fuzzy comparison Ruby code:
i just realized i could override Wildcard#=== instead of special casing it, hello revisiting throw-away toy project from three years ago
|
# ? Aug 5, 2012 19:29 |
|
Cocoa Crispies posted:yeah that uses the "===" in ruby which does a fuzzy comparison This does sound more like dynamic dispatch (CLOS-like) than pattern matching. You have to add something a bit like clojure's destructuring bind to it. Here's in Racket how you could pattern match on a list: code:
Racket has it powerful as hell -- you can expand it to use arbitrary data structures or even regexes: code:
Pattern matching goes one step further than just destructuring binds or dynamic dispatch.
|
# ? Aug 5, 2012 19:44 |
|
MononcQc posted:The important thing is that everyone should be using it in that community. for what?
|
# ? Aug 5, 2012 19:45 |
|
vapid cutlery posted:for what? condition branching/control flow and a large part of assignment in that language.
|
# ? Aug 5, 2012 19:46 |
|
MononcQc posted:condition branching/control flow and a large part of assignment in that language. i'm not really convinced
|
# ? Aug 5, 2012 19:48 |
|
You really need pattern matching and unification. Also backtracking.
|
# ? Aug 5, 2012 20:19 |
|
oh cool the "everyone should use hard computer science to write their applications" crew is out in force. cya
|
# ? Aug 5, 2012 20:20 |
|
i recommend some duck typing in your next program. make sure its duck typed. you gotta do it
|
# ? Aug 5, 2012 20:24 |
|
duck typing is wack
|
# ? Aug 5, 2012 20:29 |
|
moé! duck typing is moé!
|
# ? Aug 5, 2012 20:29 |
|
my programs are swan typed in the sense that users often break their arms while using them
|
# ? Aug 5, 2012 20:31 |
|
lmao php doesn't have a library function for building paths
|
# ? Aug 5, 2012 20:51 |
|
have you tried: autovivification?
|
# ? Aug 5, 2012 20:54 |
|
vapid cutlery posted:lmao php doesn't have a library function for building paths you mean it doesn't have a concatenation operator?? wtf
|
# ? Aug 5, 2012 20:59 |
|
Jonnty posted:you mean it doesn't have a concatenation operator?? wtf that isn't all there is to a function like that
|
# ? Aug 5, 2012 21:00 |
|
vapid cutlery posted:that isn't all there is to a function like that i get super upset at double slashes in my paths too
|
# ? Aug 5, 2012 21:01 |
|
Jonnty posted:i get super upset at double slashes in my paths too typical PHP developer settling for mediocrity and rewriting the same thing a hundred times i guess
|
# ? Aug 5, 2012 21:06 |
|
vapid cutlery posted:oh cool the "everyone should use hard computer science to write their applications" crew is out in force. cya lol basically think of how you open a file in c C code:
C code:
if that's a "hard computer science" thing maybe you should look into php/jquery
|
# ? Aug 5, 2012 21:12 |
|
Cocoa Crispies posted:lol that's a nice trivial example that can actually be written in C in fewer, easier to understand lines than what you posted
|
# ? Aug 5, 2012 21:15 |
|
i'm looking through the php api docs and apparently everyone has their own way of parsing and gluing together URL's from individual components. that's pretty loving hilarious for a language that lives on web servers
|
# ? Aug 5, 2012 21:18 |
|
vapid cutlery posted:oh cool the "everyone should use hard computer science to write their applications" crew is out in force. cya It's actually simpler using it. The example below creates a little hash with 3 users as keys, and the value for each is a list of their password and a secret to return whenever the password is right. Here's the hash definition: code:
this is how it's done in racket: code:
Here's the same function implemented using pattern matching: code:
E: usage code:
MononcQc fucked around with this message at 21:22 on Aug 5, 2012 |
# ? Aug 5, 2012 21:20 |
|
vapid cutlery posted:i'm looking through the php api docs and apparently everyone has their own way of parsing and gluing together URL's from individual components. that's pretty loving hilarious for a language that lives on web servers this is desired behavior. you just don't get php apparently
|
# ? Aug 5, 2012 21:21 |
|
MononcQc posted:It's actually simpler using it. The example below creates a little hash with 3 users as keys, and the value for each is a list of their password and a secret to return whenever the password is right. it would be nice if you used a language that was actually relevant, or even comprehensible
|
# ? Aug 5, 2012 21:22 |
|
those loving parens everywhere
|
# ? Aug 5, 2012 21:24 |
|
but but learning lisp makes you a better programmer in all languages!
|
# ? Aug 5, 2012 21:25 |
|
vapid cutlery posted:it would be nice if you used a language that was actually relevant, or even comprehensible maybe if your lovely language of choice supported pattern matching I could show the features, but your language sucks because it doesn't have pattern matching.
|
# ? Aug 5, 2012 21:25 |
|
MononcQc posted:maybe if your lovely language of choice supported pattern matching I could show the features, but your language sucks because it doesn't have pattern matching. do one in haskell it probably has the least gay syntax
|
# ? Aug 5, 2012 21:26 |
|
i want to learn clojure but don't know where to start
|
# ? Aug 5, 2012 21:27 |
|
Languages that support pattern matching to some extent from the top of my head: Racket, Erlang, Mercury, Haskell, OCaml, Mathematica, Elixir, REBOL, SNOBOL, Scala, SML, io, etc.
|
# ? Aug 5, 2012 21:28 |
|
A better language would have:code:
|
# ? Aug 5, 2012 21:29 |
|
salted hash browns posted:i want to learn clojure but don't know where to start 4clojure.org
|
# ? Aug 5, 2012 21:31 |
|
did i ever mention that thiscode:
|
# ? Aug 5, 2012 21:33 |
|
salted hash browns posted:i want to learn but don't know where to start
|
# ? Aug 5, 2012 21:33 |
|
MononcQc posted:Languages that support pattern matching to some extent from the top of my head: drat. it's like the greatest hits of toy research languages
|
# ? Aug 5, 2012 21:33 |
|
Otto Skorzeny posted:did i ever mention that this so what is this? clojure supports using cons, but not pairs? I guess that's a way to protect yourself from "lists that don't end right".
|
# ? Aug 5, 2012 21:34 |
|
|
# ? Jun 11, 2024 16:16 |
|
vapid cutlery posted:drat. it's like the greatest hits of toy research languages erlang's not so much a toy research language as a Serious Production Language for infrastructure like telephone switches
|
# ? Aug 5, 2012 21:34 |