|
cl is one of the best language standardization efforts ever, but it is still pretty much a dead end and the ecosystem is still fractured. clisp is the wrong place to start, sbcl is more workable, but just going with the free version of allegro common lisp is probably the best bet if your loving around doesn't require open source. Practical Common Lisp is actually a really well written and pragmatic book http://www.gigamonkeys.com/book/
|
# ? May 20, 2014 14:34 |
|
|
# ? May 26, 2024 07:49 |
|
MeramJert posted:this is yet another american thing though. other places use grams and it's way better nah not necessarily british/australian recipes all use cups too
|
# ? May 20, 2014 14:36 |
|
what's the advantage of lisp over haskell? i don't know either very well (did euler project problems in haskell, never touched lisp)
|
# ? May 20, 2014 14:39 |
|
~Coxy posted:nah not necessarily british/australian recipes all use cups too oh, well i guess i havent seen many of those. apparently its an anglophone problem
|
# ? May 20, 2014 14:48 |
|
Shinku ABOOKEN posted:what's the advantage of lisp over haskell? i don't know either very well (did euler project problems in haskell, never touched lisp) theyre hardly comparable, really
|
# ? May 20, 2014 14:49 |
|
Shinku ABOOKEN posted:what's the advantage of lisp over haskell? i don't know either very well (did euler project problems in haskell, never touched lisp) common lisp is very much multi-paradigm, the object system is actually very good, though weird from the java perspective. classic lisp tomfoolery with syntax is also a big part. being an ansi standard with a bunch of implementations (with support and so on) is also an advantage, though i think the sort of market appeal side of thing is silly for both cl and haskell since neither is about to burst onto the scene and grab any real market share
|
# ? May 20, 2014 15:00 |
|
lisp is a lot simpler
|
# ? May 20, 2014 15:37 |
|
Pie Colony posted:lisp (is (a ((lot) simpler)))
|
# ? May 20, 2014 16:08 |
|
'(lisp is a lot simpler)
|
# ? May 20, 2014 16:12 |
|
~Coxy posted:nah not necessarily british/australian recipes all use cups too british recipes use ounces or grams (often both are given). even fluids are measured in fluid ounces, pints, or millilitres, but never cups.
|
# ? May 20, 2014 20:38 |
|
Luigi Thirty posted:i recently discovered lisp and it seems pee cool to mess around with but how do i make it talk to a mysql? there's like five zillion libraries with lovely documentation and they all don't work unless you have a specific lisp implementation pirated from a DEC backup disc in 1975 or whatever the gently caress. i'm just using whatever apt-get install clisp downloaded i ain't got time for that jibba jabba now u know why no one uses lisp
|
# ? May 20, 2014 22:34 |
|
i write so little code these days that when i do have to hack out a script, simple things get my brain twisted every which way. i just need to loop over a list of strings, run a command on each one, and retry that command x times or until it succeeds (whichever comes first). first i'll try "while true" and break out of that when i'm done; then i decide it would be better to just have a for loop that runs as many times as you've set the retry to or until the thing succeeds; then i think maybe the most "elegant" way to do it is something functional involving recursion. i tell myself i need to stop trying to be clever and/or elegant, but i can imagine the shame if i do something "wrong" and some real developer sees it. they're all gonna laugh at me i wasn't always this stupid, honest
|
# ? May 22, 2014 20:03 |
|
option paralysis is a thing, lots of people (including myself) suffer from it assuming you're using python or whatever, a for-loop using break when it succeeds is probably the way I'd do it (TCO ) code:
code:
|
# ? May 22, 2014 21:21 |
|
AlsoD posted:
what does the ! in the pattern mean ?
|
# ? May 22, 2014 21:25 |
|
apt gangbang posted:what does the ! in the pattern mean ? it means that n is strict i.e. is evaluated immediately. actually the ! should be in the first line rather than the second but whatever. making accumulator variables strict is important to stop memory leaks e: poo poo it's not even needed since you're checking if it's <= 0 anyway. ~laziness~ gonadic io fucked around with this message at 23:11 on May 22, 2014 |
# ? May 22, 2014 21:28 |
|
AlsoD posted:option paralysis is a thing, lots of people (including myself) suffer from it this is python, in fact -- i'll give that one a shot. looks straightforward
|
# ? May 22, 2014 21:41 |
|
it's also pretty easy to modify it to return whether or not it succeeded (True or False) or now many tries it took (None if it never succeeded else some int) depending on your needs
|
# ? May 22, 2014 21:48 |
|
prefect posted:i write so little code these days that when i do have to hack out a script, simple things get my brain twisted every which way. i just need to loop over a list of strings, run a command on each one, and retry that command x times or until it succeeds (whichever comes first). first i'll try "while true" and break out of that when i'm done; then i decide it would be better to just have a for loop that runs as many times as you've set the retry to or until the thing succeeds; then i think maybe the most "elegant" way to do it is something functional involving recursion. i tell myself i need to stop trying to be clever and/or elegant, but i can imagine the shame if i do something "wrong" and some real developer sees it. they're all gonna laugh at me I used to overthink a lot this kind of stuff. I guess I got better when I started to regularly do problems. Like I'm pretty sure I won't be able to find the most elegant way to do it right away, but I'll get the obvious non-dumb way first for sure. I dunno, after solving 2105152 trivial fizzbuzzes you get some results of your previous overthinking cached in your mind.
|
# ? May 22, 2014 21:54 |
|
Symbolic Butt posted:I used to overthink a lot this kind of stuff. I guess I got better when I started to regularly do problems. unsurprisingly, this applies to pretty much every creative process
|
# ? May 22, 2014 23:08 |
|
var res = String.join(Array.reverse(str.split(' '))); i think wait is this not the thread where we were janitoring strings? whatever
|
# ? May 22, 2014 23:10 |
|
Array.reverse returns void also you need String.join (" ", ...) instead but whatever e: all programmers are terrible anyway
|
# ? May 22, 2014 23:14 |
|
eh w/e close enough considering i missed the right thread c#'d at least be nice enough to tell me that was wrong who nkwos what java script or php wouldve done probably farted out an ugly string of garbage tho
|
# ? May 23, 2014 00:02 |
|
web devs call it html
|
# ? May 23, 2014 00:12 |
|
i cant do anything in javascrapt except use jquery
|
# ? May 23, 2014 00:16 |
|
Valeyard posted:my cups are fuckin hugee loll, gynocomastia that bad huh?
|
# ? May 23, 2014 00:40 |
|
carry on then posted:gynocomastia that bad huh? lol
|
# ? May 23, 2014 02:44 |
|
AlsoD posted:option paralysis is a thing, lots of people (including myself) suffer from it In Python this is absolutely the way to do it, so much so that Python has the for else construct, really useful for finding the first thing that passes some requirement: code:
|
# ? May 26, 2014 16:58 |
|
I'll admit that I only use for else when I'm feeling like an rear end in a top hat because the most common thing to do is to just use some flag variable. pretty sure it doesn't slow down the code in any significant way. I think I read somewhere that Knuth came up with this construct in response to covering every use case for goto. thanks knuth
|
# ? May 26, 2014 23:39 |
|
i found myself using any() and all() with a generator comprehension over for-else
|
# ? May 27, 2014 00:21 |
|
i.e. if any(thing(x) for x in things): .... if all(f(i) for i in range(n)) ....
|
# ? May 27, 2014 00:22 |
|
tef posted:i.e. this is rad and makes me hate python just a little bit less
|
# ? May 27, 2014 00:24 |
|
Notorious b.s.d. posted:this is rad and makes me hate python just a little bit less i kinda wish they'd removed for-else. if anything, for-then would be a better name for the semantics it has. i always expected to have for-else in python work like: for .. else if there are zero elements, ..... and not for ... else if no break
|
# ? May 27, 2014 00:55 |
|
Raymond Hettinger is a huge proponent of for-else, I was thinking about it and there's this example in his slides: https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1?slide=11 and you can still use a comprehension here instead of for-else, because comprehensions are loving awesome Python code:
|
# ? May 27, 2014 01:30 |
|
why isnt ocaml's map tail recursive
|
# ? May 27, 2014 04:36 |
|
for else looks gross
|
# ? May 27, 2014 04:42 |
|
apt gangbang posted:why isnt ocaml's map tail recursive for most map operations on lists and whatever finite data structure, no matter the language (as long as it's immutable and strict), it may be faster to use a body-recursive version. Basically, the cost on stack will likely be little more than the duplication of pointers for the function you're using to map, and the pointer to the data structure you're mapping over. The data structure you're passing in basically limits how deep the stack goes. So you get two lists: the original one, and the mapped one. You've had an overhead of a couple pointers per list element to go with it, along with wherever the function returns. OTOH, a tail recursive map will need to generate a second list anyway, and do it in a reverse-manner by prepending to the head of the list if immutable, to avoid the cost of rewriting the list on every traversal. The end-result of this is that you then need to reverse the list at the end, creating a total of 3 lists: the original one, the intermediary one, and the final one (reversed intermediary). The tail-recursive map may overall have required more memory than the body-recursive one, potentially triggering GC and whatnot. That's super dependent on the language and its implementation, of course, but there are definite cases where a tail-recursive map can be seen as worse than a body-recursive one. You can benchmark them under different circumstances and see.
|
# ? May 27, 2014 04:45 |
|
if you need a tail-recursive map in ocaml, get extlib, which includes a drop-in tail-recursive replacement with no performance penalty. (it avoids having to build the list backwards and reverse it by using a mutable data structure with the same memory representation as a list and then subverting the type system to turn it into one. don't try this at home.)
|
# ? May 27, 2014 10:22 |
|
tef posted:i.e. Doesn't give you access to x though, also means you can't log. I like for else, it makes perfect sense to me.
|
# ? May 27, 2014 10:41 |
|
Soricidus posted:if you need a tail-recursive map in ocaml, get extlib, which includes a drop-in tail-recursive replacement with no performance penalty. unsafeCoerce is the best coerce
|
# ? May 27, 2014 11:17 |
|
|
# ? May 26, 2024 07:49 |
|
Zombywuf posted:In Python this is absolutely the way to do it, so much so that Python has the for else construct, really useful for finding the first thing that passes some requirement: i had not been aware of this -- it feels weird to me (and it really makes me wish there were curly braces to organize this stuff), but it looks super-useful tef posted:i.e. i don't think this would work for what i'm trying to do (what i've done, actually -- once i put my head down and picked a way to do it, it came together (ugly, but functional)), since i want to execute a command only until it succeeds. would "if any(thing(x) for x in things)" execute the command even after a successful attempt?
|
# ? May 27, 2014 13:07 |