« first day (5 days earlier)      last day (1726 days later) » 

3:48 AM
Hello again, I'm having trouble with the following code f a=[a!!i<$[1..(f a)!!i]|i<-[0..]]
Theoretically it should take a[i] from array a, such as [2, 3, 1] and append a[i] to the new list a[i] times, using n<$[1..n]. Is there a way to concatenate n<$[1..n] instead of adding as a list inside a list?
 
4:34 AM
Ah nuts. I forget that a!!i in the beginning should be (cycle a)!!i
 
 
3 hours later…
7:58 AM
@Sherlock9 I'm not exactly sure what you are trying to do, but you can add concat (or id=<<) in front of the list comprehension to get it to type: Try it online!
 
@Laikoni Thanks for the help. I'm trying to do this challenge
 
There was also a $ missing behind take 25.
 
Hm, as I expected I do need to initialize the array. That's going to eat a lot of bites
Also how would I put take in f?
 
Exactly, otherwise the self reference can not be resolved.
 
8:04 AM
@Sherlock9 You probably can't because of the self reference, but take 25.f would work. Or is the 25 also an input?
 
25 is an input
 
8:35 AM
Hm, maybe I can do take n in a function below the main list comprehension instead
 
9:00 AM
I think (cycle a) is the problem, it producs an infinite list
(not sure yet)
 
@Sherlock9 <$ binds weaker than ++
You need to enclose the initialisation in parentheses.
 
And as long you don't have any guards [...|i<-[1..]] can usually be shortened using map or <$>
For some reason I keep thinking about an ice cream cone whenever I see <$
 
@flawr I'm having trouble figuring how to use map and <$> because the i variable is used in several different places
I may just need to learn more about lambda calculus reduction methods
 
ah right this seems to be getting longer
 
I also think about a double-scoop ice cream cone when I see <$
 
9:07 AM
@Sherlock9 high five:)
But you could simplify the a!!0 with f a|z<-a!!0=(z<$[1..z])...
 
Excellent. 84 bytes now since I have to put take in the main code.
 
and I think you don't need the parentheses around f a and cycle a
 
@Laikoni Before I forget, thank you very much :D
And we're down to 80 bytes. Is a shorter way to write ++concat?
 
id=<< is a shorter concat
 
Ah, sorry you already said and I forgot to try it
Hm. An error
 
9:12 AM
@Laikoni you need to add that to the tips!
 
@Sherlock9 Oh, ok, it does not work with the ++ in front
 
I think you have to put parens because of weaker binding :/ 80 bytes earlier vs 79 bytes now
 
a#n=take n$f a can be shortened to (.f).take if the arguments are reversed.
 
n#a=(.f).take is giving me another error
 
It's point free, you don't need n and a as arguments.
Like this: [Try it online!](https://tio.run/##y0gszk7Nyfn/P00hsabKRjdRUdHANjk/LzmxREWjykYl2lBPrypW0‌​yo6uTI5J1UBKJ0JEUwDs2NrMm10QdzYWK50Ww29NE29ksTs1P@5iZl5CrYKBUWZeSUKKgrpCkamCtFGOs‌​Y6hrH/AQ "Haskell – Try It Online")
 
9:17 AM
Ah of course. Just need another single-character function name because #=... gives another error
 
@Sherlock9 well only as concatMap f, I the concat is probably used more often.
@Sherlock9 you'd have to write (#)=...
 
Which brings us to 79 bytes
 
@Laikoni how do you come up with solutions like that? I'm getting dizzy by just looking at it!
 
@Laikoni that was not what I hoped to hear :D
 
Anonymous
9:23 AM
pointfree.io is how I make myself look like I know way more about Haskell than I do :P
 
Does anyone know, is it possible to add links in the room description?
 
Anonymous
Yep
 
@Sherlock9 Anonymous functions are allowed, so you don't need to count the (#)=.
 
Anonymous
See: TNB
 
I mean using []()?
Or can you just past URLs?
 
9:24 AM
@Sherlock9 70 bytes
 
Anonymous
Just paste URLs
 
Anonymous
No Markdown in room descriptions, unfortunately
 
@flawr Well, at least by now I usually understand the transformations and also do them myself in simple cases.
 
Hm, I'll have to practice a little bit then:)
@Laikoni Do you mind if I add the tips for golfing in haskell in the room description? (perhpas also pointfree.io?)
 
@Laikoni Many thanks :D I'm going to write up my answer. Is it alright if in my answer I write the following: Many thanks to Laikoni and flawr for their help in debugging and golfing this answer in the PPCG Haskell chatroom, Of Monads and Men
 
9:27 AM
@flawr Sure, go ahead.
 
Anonymous
Credit and advertisement, nice double-whammy
2
 
room topic changed to Of Monads and Men: For discussion about, learning of and golfing in Haskell codegolf.stackexchange.com/questions/19255/… pointfree.io [haskell]
too bad it doesn't just show the title of the question =/
 
Anonymous
I thought you actually did it there, and was confused why it didn't change on the side
 
The Guide to Golfing Rules in Haskell is also a good place to link to.
 
Oh yeah, is there something else to add?
One could also link these in the description
ok this is strange: I recently pinned this CMS you can still see on the starboard, without actually starring it - now that I've unpinned it it looks like I starred my own message (but cannot unstar it)
and if I try to unstar it it says "you cannot star your own message" as if I haven't starred it yet.
 
9:32 AM
@Sherlock9 I like that. Also 68 bytes
 
Anonymous
@flawr Yep, known bug.
 
Anonymous
As with all chat bugs, it has existed for quite a while, and SE has made no visible effort to fix it or even acknowledge it
 
@Laikoni Well, I was starting to explain the 70-byte one, but that's gone and confused me
Oh wait
 
@Mego ok at least it was not me doing something wrong:)
 
a@(z:_) is just defining a and defining z as the head
 
9:33 AM
Also shouldn't ROs be able to clear stars?
 
Anonymous
They should be able to
 
Anonymous
You use the cancel stars button from the starboard, not unstarring
 
Ah that was what I was looking for! Thanks a lot!
"Remove the stars against this post."
 
Anonymous
Glad to help :P
 
I just added some links to the haskell tag description: codegolf.stackexchange.com/tags/haskell/info
 
Anonymous
I got to figure all this stuff out by myself when I was added as a TNB RO :P At least you're not having to try to find the button during a star spam wave
 
Ah, trial by fire
 
Anonymous
Trial by fire with gasoline
 
Or since it's stars, perhaps, trial by meteor shower
 
Anonymous
That's pretty accurate :P
 
Anonymous
9:41 AM
I can't remember the last time I had to cancel stars, though, so things have gotten better
 
Anonymous
Either that or I've just gotten luckier and not been around for it
 
flawr has made a change to the feeds posted into this room
flawr has made a change to the feeds posted into this room
 
@Feeds Oh, nice.
 
32
A: Point Free problems in Haskell

luquiConverting to pointfree style can be done entirely mechanically, though it's hard without being comfortable with the fundamentals of Haskell syntax like left-associative function application and x + y being the same as (+) x y. I will assume you are comfortable with Haskell syntax; if not, I sug...

@Laikoni @Mego ^ provides an algorithm for making thins pointless
 
Anonymous
9:59 AM
@flawr Oh, I'm aware :) pointfree.io (and the pointfree package it uses) uses that algorithm, I believe
 
Thanks for the link. Reading it now
Did we actually get 5 Haskell questions at once, or is this Feeds trying to catch up?
 
Anonymous
Probably the latter
 
Oh no, can I delete these messages somehow?
 
Anonymous
You can move them to Trash
 
Anonymous
You might need to get access, though, since it's a gallery room
 
Anonymous
10:04 AM
I think ArtOfCode is the one to ping
 
Anonymous
Apparently this guy is the sole RO of Trash, but I think Art used his diamond powers to give the TNB ROs write access so we could move trash there
 
^ this is what I feel like :D
 
Anonymous
Too much RO power? :P
 
10:28 AM
0
A: Tips for golfing in Haskell

flawrConverting to Pointfree Als @Laikoni already mentioned there is pointfree.IO, but if you want to do this conversation manually you can check out this answer on stackoverflow by @luqui, which provides an algorithm: You need the following combinators, which are in the standard library. I hav...

 
@flawr May edit your post in Haskell tips for clarity?
 
@Sherlock9 sure!
 
Done!
 
 
1 hour later…
11:56 AM
14 messages moved to Trashcan
@flawr I'm not reading the contents of that room this time... It's scary.
 
Is it possible to trash things as RO?
 
@flawr It's possible to move things from any room you are RO in to any room you have access to, iirc.
Try moving this message to the Sandbox.
 
1 message moved to Sandbox
Ah now I see, thanks a lot!
 
But that should never be done.
 
Best if we don't tell anyone :)
Thanks a lot for your help!
 
12:04 PM
It's one of the less important abuses because it's obvious when it's being done.
 

« first day (5 days earlier)      last day (1726 days later) »