« first day (1833 days earlier)      last day (235 days later) » 

12:55 AM
(foldl (q(A B) (* A B)) (1to 10)) What am I doing wrong?
I know I could just give * to foldl but I'm trying to figure out how to supply an arbitrary lambda.
 
1:12 AM
@chunes Looks like you're passing multiple arguments to q. Try (q ((A B) (* A B))) instead.
 
Oh, something really dumb. I'm pretty new to lisp, you can probably tell. Hard to keep track of all the parenthesis
 
Yeah, it can be a bit confusing because the two ways to define a lambda are (q ((A B) (* A B))) and (lambda (A B) (* A B)). lambda is a macro that takes two arguments, the function args and the function body. q is just the quoting builtin, so it always takes one argument; to make a function, that argument should be a two-element list.
 
Makes sense
 
1:27 AM
Also, your commented/ungolfed answers have been golden for getting up to speed. Nice work on those
 
 
1 hour later…
2:49 AM
codegolf.stackexchange.com/questions/242257/… the lack of negative numbers makes this unendingly painful
 
3:48 AM
@DLosc that moment when string lib with no split function
 
3:59 AM
(d split (q ((A C S) (if A (if (e (h A) C) (c (reverse S) (split (t A) C ())) (split (t A) C (c (h A) S))) ()))
done
 
@chunes Hey, thanks! Glad to hear that it's helpful. I'm a big proponent of explanations.
@Razetime Yeah, string support is... "basic" is too generous. It was very much an afterthought--tinylisp was always supposed to be just integers and lists, but somebody asked for strings at one point and I thought, "Well, I guess it wouldn't hurt to treat names as strings."
 
4:21 AM
names as strings is so funny
i love that idea
but the result is you always need a quoted codepoint array to represent string
which isn't the most terrible thing
 
@Razetime It can lead to some funny situations if you play around with it. For example, the empty string is a perfectly valid name that you can define; you just can't refer to it directly, you have to construct code and eval it. TIO
@Razetime Not sure what you mean--any string without spaces or parens in it is just (q your_string_here)
 
4:36 AM
@DLosc yeah but obviously we need both
and newlines lmao
 
DLosc might have to rename it to Sorta minimal lisp afterward
 
@Razetime Yeah. That's why the little that is in string.tl does include space, newline, and converting a codepoint to a single character. (I'm a bit disappointed looking at it now that I didn't think to include an empty-string definition, but (string ()) isn't so bad I guess.)
 
well tinylisp ain't made for golfing
 
@chunes This is part of why I've historically resisted adding more features to the core language. It's supposed to be tiny. :)
 
but that bracket autocompletion is such a godsend sometimes
 
4:43 AM
True dat.
HBL is me trying to take that idea as far as it'll go and make a Lisp that's actually golfy. I think it could potentially end up being the golfiest Lisp dialect (right now it's suffering from being severely underdeveloped), but I don't think any Lisp will ever be as golfy as the tacit and stack-based languages. Parentheses just cost bytes, there's no way around it.
 
Unless... we use capitalization to encode nesting levels
please forget I said that
It wouldn't even work anyway if all the names are 1 byte
But a lisp program that looks like forth would be a trip
Also everything would have to have specific arities, I guess. So total failure of an idea
That's the one thing that is really different about lisp that will take some getting used to. The idea that you get varargs 'for free'
 
4:58 AM
@chunes Failure is just part of the process of generating good ideas.
 
Oh, I guess tinylisp doesn't work that way.
(a 1 2 3) throws an error where (+ 1 2 3) works in most lisps I think
 
Yeah, tinylisp is unusual among Lisps in that way. I did it that way to make it simpler to implement.
But there are variadic versions in the library.
 
I see
 
mul2 and div2 are dyadic, while * and / are variadic (and product takes a single argument, a list).
 
 
8 hours later…
12:56 PM
(d C(q((N R)(i N (i R (a (C (s N 1) (s R 1)) (C (s N 1) R)) 0) 1)))
is this a correct combinations function
sometimes i wish tinylisp pointed to the paren that was wrong
 
 
5 hours later…
6:00 PM
@Razetime Looks like the parentheses all match up correctly (though you're missing one at the end if you don't want to rely on autocomplete parens). The recurrence relation looks right, but I think the base cases are wrong. This should give (1 4 6 4 1).
That probably won't be the golfiest way, but it gives you something to check against.
Looks like you just need to swap the order of the ifs: Try it online!
 

« first day (1833 days earlier)      last day (235 days later) »