ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
Sankalp has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
Sankalp has joined #crystal-lang
Sankalp has quit [Client Quit]
Sankalp has joined #crystal-lang
Sankalp has quit [Client Quit]
Sankalp has joined #crystal-lang
jmd_ has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Quit: Leaving]
hholst has joined #crystal-lang
<hholst> what would the idiomatic way be to do this in crlang?
<FromGitter> <Blacksmoke16> probably just like `x.permutations(1) + x.permutations(2) ⏎ `
<FromGitter> <Blacksmoke16> or ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=62eea74372ad51741fe49e8f]
<hholst> can you reduce an array with concat as operation?
<hholst> if so I could do maybe (1..2).map({ |n| x.permutations(n) }).reduce ???
<FromGitter> <Blacksmoke16> i think the most optimal would be something like this
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/dkiu
<FromGitter> <Blacksmoke16> new up some output array, using some heuristic to allow it to allocate once, use the block version of `each_permutation` to yield each permutation and push it to the allocated array
<FromGitter> <Blacksmoke16> most optimal that i could think of off the top of my head*
<hholst> what would be more useful, to return a list or to yield?
<hholst> in python you would typically yield and the function would return an iterator, and then cast that to a list if need be
<hholst> is it more useful to have a block consuming function than to return a list of object like I did here?
<hholst> like that
<hholst> of the size stuff heuristic would need to move outside as well
<hholst> binom(3,1) + binom(3,2) would be the size btw :)
<hholst> I think... no wait. its permutations not combinations.. ok probably more complex
<hholst> I am rewriting a python microservice that computes sub sums of numbers (amounts in an invoice). mostly for fun but also because the python code is kinda slow
Sankalp- has joined #crystal-lang
Sankalp has quit [Ping timeout: 268 seconds]
Sankalp- is now known as Sankalp
<FromGitter> <HertzDevil> `x.each_permutation(1).chain(x.each_permutation(2))` 😂
jmdaemon has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 252 seconds]
<FromGitter> <threez> Hi I created a shard for PDF writing. I would like to get feedback as this is my first bigger crystal project. Maybe somehow here has the time for a review? https://github.com/threez/hpdf.cr
hholst has quit [Quit: Client closed]
<SamantazFox> threez: I haven't dug much into the functionality, but I can say that the code is very clean! I particularly appreciate the comments :)
ngp has joined #crystal-lang
<FromGitter> <Blacksmoke16> could consider using enums for some stuff instead of modules with constants
<FromGitter> <Blacksmoke16> would need to use another method to return the string representation tho, if you need those specific values
<SamantazFox> Ohhh, TIL that you can combine operators :O
<SamantazFox> Blacksmoke16: I should probably read that again, as it had quite changed since my last full read (around the 0.36 days)
<FromGitter> <Blacksmoke16> 1) 36 was the one right before 1.0, cant imagine *too* much changing
<SamantazFox> just checked, the operator chaining wasn't in here ^^
<FromGitter> <Blacksmoke16> ah yea, improvements to the docs happen often, but its not a new feature