• cheeser
  • ernimril
  • joed
  • kinabalu
  • lunk
  • ojacobson
  • r0bby
  • ThaDon
  • ricky_clarkson
  • topriddy

« 2021-05-04


2021-05-06 »

Nick Message Date
ufobat [ufobat!] has joined #kotlin [01:12]
w0x12ef [w0x12ef!~textual@] has joined #kotlin [01:25]
raoul11 [raoul11!~raoul11@unaffiliated/raoul11] has joined #kotlin [02:13]
mirk0 cheeser piwi what if we use the string template with jointToString for example inside triple quotes and want to separate string results with line brakes [03:30]
Bombe I totally have not bothered to find out what it is you're trying to do but what happens if you just do it? [03:30]
mirk0 Tried using System.lineSeparator() and it ruins the whole format for some reason [03:33]
mirk0 maybe it's the library I'm using and passing the string to that it replaces it with something else, I'll test it thorougly [03:35]
halvors [halvors!] has joined #kotlin [03:39]
piwi [04:04]
piwi piwi's title: "Kotlin Playground: Edit, Run, Share Kotlin Code Online" [04:04]
piwi that works for me as expected [04:04]
jacob [jacob!~jacob@unaffiliated/jacob] has joined #kotlin [04:13]
Lengsdorfer [Lengsdorfer!~Lengsdorf@unaffiliated/lengsdorfer] has joined #kotlin [05:05]
whaley [whaley!] has joined #kotlin [06:16]
DTZUZU [DTZUZU!] has joined #kotlin [06:49]
computeiro [computeiro!~Wender@] has joined #kotlin [07:12]
wender [wender!~Wender@] has joined #kotlin [07:16]
computeiro [computeiro!~Wender@] has joined #kotlin [07:19]
Suchorski [Suchorski!~regex@unaffiliated/suchorski] has joined #kotlin [08:14]
whaley [whaley!] has joined #kotlin [09:02]
piwi [piwi!] has joined #kotlin [09:52]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [10:23]
jacob7 [jacob7!~jacob@unaffiliated/jacob] has joined #kotlin [10:58]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [11:43]
sec0nd [sec0nd!~second@gateway/tor-sasl/sec0nd] has joined #kotlin [12:06]
orbyt_v7 [orbyt_v7!~textual@] has joined #kotlin [12:26]
zutat [zutat!~ben@unaffiliated/zutat] has joined #kotlin [12:27]
zutat good evening [12:28]
dbohdan parted the channel: [12:32]
zutat let's do functional style programming with the kotlin stdlib [01:40]
cheeser also consider arrow [01:41]
zutat let's say that i would have a Collection<T> to begin with, which is guaranteed to have an even length [01:41]
zutat and would like to produce pairs of consecutive elements (without reuse of elements) [01:43]
ricky_clarkson zutat: Sounds like a use for yield - [01:44]
ricky_clarkson ricky_clarkson's title: "yield - Kotlin Programming Language" [01:44]
squirrel or probably use chunked() [01:48]
ricky_clarkson You could probably do something similar with filterIndexed and map [01:48]
ricky_clarkson zipWithNext [01:49]
zutat there's zipWithNext? [01:49]
cheeser that's what i was just ppulling up [01:49]
cheeser [01:49]
cheeser cheeser's title: "zipWithNext - Kotlin Programming Language" [01:49]
cheeser as with any library it helps to get familiar with the API docs [01:49]
squirrel `listOf(1,2,3,4).chunked(2).map { (a, b) -> Pair(a, b) }` [01:50]
cheeser although that may not be quite what you want. [01:50]
cheeser since every list element but the last will be the first() in a List<Pair> [01:51]
zutat looks like i've missed zipWithNext, but it also doesn't do what i want. i wanted a, b, c, d to (a, b), (c, d) [01:51]
squirrel did i mention chunked? [01:51]
squirrel i think maybe i should mention chunked [01:51]
ricky_clarkson chunked generates a List<List<T>>, not sure if there's a chunkedSequence, I see one defined but only for CharSequence. [01:51]
cheeser yeah. squirrel has the right answer. [01:51]
ricky_clarkson generating intermediate lists can be heavy for some use cases [01:52]
cheeser something tells me perf is not a concern here. :) [01:52]
zutat squirrel: yes. your chunked solution seems good :) i was using chunked, too, but didn't use destructuring in the lambda. nice [01:52]
squirrel sequence {} is going to be way heavier [01:52]
cheeser those intermediate List are likely subviews of the original. i don't imagine it's that heavy. [01:53]
cheeser it *is* O(n^2) probably, though. [01:53]
ricky_clarkson Actually can be shortened to just chunked avoiding an intermediate List - [02:08]
ricky_clarkson ricky_clarkson's title: "Retrieve collection parts | Kotlin" [02:08]
ricky_clarkson numbers.chunked(3) { it.sum() } [02:09]
ricky_clarkson kotlin++ [02:09]
ricky_clarkson kotlin has a karma level of 20, ricky_clarkson [02:09]
ricky_clarkson Hmm, there's still an intermediate list but maybe it has a more efficient representation (view) - "When chunked() is called with a transformation, the chunks are short-living List s that should be consumed right in that lambda" [02:11]
squirrel oh good find ricky_clarkson [02:27]
computeiro [computeiro!~Wender@] has joined #kotlin [02:33]
zutat the names are getting too long :S firstNotNullOfOrNull [02:38]
zutat (new in 1.5) [02:39]
cheeser agreed [02:47]
cheeser too many convenience methods. [02:47]
squirrel might be nice for finding stuff in lists using takeIf or sth [03:05]
ricky_clarkson OrNull should in my view just be expressed in the return type [03:35]
ricky_clarkson so firstNotNull would be enough in the function name. [03:35]
zutat ricky_clarkson: but there is no way to overload by return type [03:37]
ricky_clarkson Ah, there's already a firstNotNull? Does it throw an exception if there's nothing found? [03:39]
ricky_clarkson Ok, firstNotNullOf already exists and throws [03:41]
ricky_clarkson I saw that Guava's similar methods like getOnlyElement, or toOptional (a Stream -> Optional collector) are commonly quoted in outage post mortems.. [03:43]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [04:16]
LuxuryMode [LuxuryMode!uid91005@gateway/web/] has joined #kotlin [04:29]
shailangsa does anybody know why gives unresolved reference and doesn't and if it is possible to define a function within main(), why can't it be called too? [04:40]
cheeser what's the actual error? [04:46]
shailangsa the first one gives unresolved reference for readFileAsLinesUsingReadLines ? [04:46]
cheeser move that function def up [04:47]
Bombe Yeah, you?re using it too early! [04:47]
shailangsa otherwise define it outside of main? [04:48]
cheeser yes [04:48]
squirrel oo new release cycle [05:06]
squirrel they are keeping current major version though, i wonder when we'll see 2.0 [05:07]
squirrel why doesn't kotlin have match expression? [05:42]
squirrel i can't even find a single discussion about it [05:42]
cheeser have a what now? [05:43]
squirrel [05:44]
piwi i guess writing a new regex engine isn't the bullet on the list [05:54]
piwi and for jvm based you can use the java one [05:54]
piwi first bullet* [05:54]
squirrel this has nothing to do with regex [05:55]
piwi ah, sorry, didnt follow the link [05:55]
squirrel rust has it, python 3.10 will have it as well, although it's a bit weird in python [05:56]
piwi whats wrong with 'when', @squirrel ? [05:56]
squirrel when can't do that `case Foo(bar_) if bar > 1` thing [05:57]
squirrel sans _ [05:58]
piwi that part called pattern guards? [05:59]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [06:02]
squirrel yes, well, the if part is boring, the interesting part is that you can get bar out of `Foo(bar)` [06:04]
FuzzyBottom Another newbie question. I am trying a codewars problem. I have to iterate over a list, but if it reaches the end of the list, it needs to start at the beginning, or the end of going backward through the list, from the first element then the next iteration is the last. I understand the next and previous, but have no idea how to start it at the beginning or end of the list. Could someone give me a hint as to what I should look [06:10]
FuzzyBottom for? Thanks [06:10]
boughtly [boughtly!~boughtly@unaffiliated/boughtly] has joined #kotlin [06:14]
ricky_clarkson squirrel: I'd like something closer to pattern matching, but I'm still getting used to Kotlin's version. [06:31]
ricky_clarkson I find flow typing odd - if (blah is Foo) { blah.fooSpecificFunction() } - I get that it's nice, but it means blah has a different type in 2 places - within and outside the if. [06:32]
ricky_clarkson Java's if (blah instanceof Foo foo) looks pretty odd but doesn't have that issue. [06:32]
squirrel FuzzyBottom: your wording is confusing. link to the problem? [06:37]
squirrel ricky_clarkson: what's `if (blah instanceof Foo foo)`? [06:38]
FuzzyBottom [06:38]
FuzzyBottom FuzzyBottom's title: "Training on Circular List | Codewars" [06:38]
FuzzyBottom basically if the list is 1,2,3, and as you iterate through the list, when 3 is reached the next time the method next() is called, it is supposed to start back at one. Same as going backward [06:39]
squirrel aha. what's the issue? [06:41]
ricky_clarkson squirrel: Java's new way of doing if (blah instanceof Foo) { var foo = (Foo) blah; ..your code here.. } [06:43]
FuzzyBottom I understand how to iterate through the list, but if 3 is reached, and it wants to start back at 1, I do not know how to make that happen. I was trying an if statement if(iterator.hasNext(), then when it reaches the end, I do not know how to tell it to go to element 0 [06:43]
squirrel ricky_clarkson: oo. i see. kind of... not bad i guess? [06:44]
ricky_clarkson FuzzyBottom: You'd want to store an index tracking how far through the list you are. [06:47]
ricky_clarkson or yeah, if you're using an iterator for that then when the iterator has no next, create a new iterator [06:47]
FuzzyBottom ricky_clarkson: like nextIndexed() sort of thing? [06:47]
squirrel iterator can only iterate once [06:47]
ricky_clarkson like var index = 0 [06:48]
squirrel this thing is supposed to iterate back and forth, you can't use it with iterators [06:48]
FuzzyBottom oh, okay. I had no idea. [06:48]
FuzzyBottom so if not iterators, I am way off base :). Back to the drawing board. [06:49]
halvors [halvors!] has joined #kotlin [06:49]
FuzzyBottom I do appreciate your help. Thanks. I will keep looking for another solution. [06:49]
FuzzyBottom ricky_clarkson: I will try working with that method now. Thanks. [06:50]
squirrel this CircularList thing is silly. at the beginning, next() returns 1st value and prev() returns last value. this makes you special-case the beginning of iteration [06:57]
squirrel a very bad data structure... [06:58]
FuzzyBottom Have you ever tried these codewars things? I find that I feel like a fool trying to work some of these out. When I try coding things on my own, I feel like I am getting somewhere, then I try these, and I feel like quitting. [06:59]
squirrel ...actually you don't need to special case, kind of (spoiler) [07:01]
squirrel i haven't tried it myself, but i wouldn't be too discouraged. you don't have to write smart algorithms and data structures too often [07:03]
FuzzyBottom Before I go to that link, is this your work? I figured someone who knows what they're doing would have the answer in minutes :) [07:07]
cheeser that's more a circular iterator than a list [07:07]
squirrel yes, that's my solution that passes the tests [07:08]
cheeser nods. [07:08]
FuzzyBottom Haha, I have been trying to sort this out for hours :) [07:08]
cheeser % would simplify that code a bit. you'd just need to check for < 0. [07:09]
FuzzyBottom So if I put it through an if statement, and if it reaches the end, start a new iterator, would that be a solution? I want to try sorting it out before seeing squirrel's answer [07:10]
squirrel FuzzyBottom: the thing about iterators, they go to one direction only. you iterate over 1, 2 using next(), and then prev() is called. at this point your iterator is useless, and you can't just make a new one as you are not at either end [07:11]
FuzzyBottom Oh, so it's more complex than I thought. [07:12]
FuzzyBottom Looking at your answer, it seems so logical, but me trying to come up with that, seemed like a stretch :) [07:13]
squirrel there's a trick in my solution. at the beginning, -1++ would be a valid index 0, but -1-- would be a bad index when going prev() [07:15]
squirrel i wrote this first before realizing i don't need the ifs :p [07:16]
squirrel and yeah you can employ % here [07:16]
ricky_clarkson Slightly different approach: [07:22]
ricky_clarkson I saw that people complained about that inconsistency regarding prev [07:22]
ricky_clarkson on the kata site [07:22]
squirrel i'd use .also {} instead of try/finally [07:23]
ricky_clarkson the try..finally is garbage left over actually [07:23]
ricky_clarkson is more like it [07:25]
squirrel aha [07:26]
ricky_clarkson lastIndex looks helpful [07:31]
FuzzyBottom It's funny how I thought I was on the right track, and it took you minutes and showed I was totally on the wrong track. Again, I appreciate your help and patience with my questions [07:41]
FuzzyBottom And sorry for the lousy wording at first. [07:42]
squirrel [squirrel!~mj@unaffiliated/squirrel] has joined #kotlin [07:43]
squirrel [squirrel!~mj@unaffiliated/squirrel] has joined #kotlin [07:50]
FuzzyBottom Okay, I will not work on that one now for a few days, in order to forget everything you both kindly showed me, so I can try it again.:) [07:52]
FuzzyBottom I have another one. I have it mostly right, but am stuck on one issue, is the problem, and my solution is [07:54]
FuzzyBottom FuzzyBottom's title: "Training on Errors : histogram | Codewars" [07:54]
FuzzyBottom The issue I have is trying to figure out if there is more than a single digit amount of errors 10+, the code fails, but less than 10 works. Would there be an if statement I would use to add to this somewhere? [07:55]
FuzzyBottom Sorry if I am annoying [07:55]
liefer [liefer!~liefer@unaffiliated/liefer] has joined #kotlin [08:00]
squirrel [squirrel!~mj@unaffiliated/squirrel] has joined #kotlin [08:02]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [08:34]
FuzzyBottom Oh, I will spend hours or days even trying to sort out a solution before asking. Just so nobody thinks I am just looking for answers. [08:35]
cheeser too late. i already regard you with utter disdain! [08:37]
cheeser UTTER! [08:37]
cheeser utter is a weird word. [08:38]
FuzzyBottom But people say I am charming. Well my mom does anyway [08:47]
DTZUZU_ [DTZUZU_!] has joined #kotlin [09:15]
dade`5 [dade`5!~dade`@nectarine/admin/dade] has joined #kotlin [09:15]
sec^nd [sec^nd!~second@gateway/tor-sasl/sec0nd] has joined #kotlin [09:18]
Lengsdorfer [Lengsdorfer!~Lengsdorf@unaffiliated/lengsdorfer] has joined #kotlin [09:18]
Cyp_ [Cyp_!~Cyp_@] has joined #kotlin [09:53]
shailangsa [shailangsa!] has joined #kotlin [09:53]
markmarkmark [markmarkmark!~mark@] has joined #kotlin [09:53]
oddalot [oddalot!] has joined #kotlin [09:53]
FuzzyBottom [FuzzyBottom!] has joined #kotlin [09:54]
Cyp_ [Cyp_!~Cyp_@] has joined #kotlin [09:54]
Arahael [Arahael!] has joined #kotlin [09:55]
cheeser /1 [10:01]
cheeser cheeser, what does that even *mean*? [10:01]
shailangsa [shailangsa!] has joined #kotlin [10:15]
squirrel jake pls [10:38]
squirrel 5k stars already :D [10:39]
cheeser i can imagine. [10:39]
cheeser i have an app or two i've been wanting to write in javafx but i started eyeballing this a few months back. [10:40]
squirrel jake used to come here on irc [10:40]
cheeser i don't remember him coming to *this* channel... [10:41]
cheeser unless he had a clever nick i didn't recognize [10:41]
squirrel i remember seeing him in #android-dev [10:42]
cheeser that's possible. i don't hang out there since i don't do android dev [10:42]
squirrel do you do scala? [10:45]
cheeser i dabbled with it years ago [10:46]
cheeser the language was ok-ish. the community was a dumpster fire. [10:46]
squirrel wdym dumpster fire [10:46]
cheeser toxic. condescending. aggressive. generally unwelcoming. full of assholes. [10:47]
cheeser the simplest of questions led to conversations of lambda calculus and all sorts of esoteric shit. [10:48]
cheeser i just wanted to get shit done and learn. [10:48]
cheeser then kotlin came on the scene 2011ish and i've been with it since. [10:48]
squirrel i thought you could same the same of #java :s [10:48]
cheeser meh. #java is fine. most of the time. :D [10:48]
squirrel i feel like #java got more welcoming over the times [10:49]
cheeser it has its moments but i work hard to keep the assholery to a minimum. [10:50]
squirrel anyway, it feels like kotlin is a bit of competitor to scala? i only learned about scala recently, the languages are kind of aiming for the same niche [10:51]
cheeser *kinda* they both get positioned by folks as "the next java" or "a better java" [10:51]
cheeser kotlin was designed to be a journeyman's language. scala was designed to push the multiparadigm OOP/functional aspects to its limits. [10:52]
squirrel ?journeyman's language?? [10:52]
cheeser not requiring high expertise in the minutia of type systems and category theory, e.g. [10:53]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [10:54]
cheeser accessible to all levels of programmers from beginners to veterans. [10:54]
squirrel i see. from what i read of scala (i didn't try it in practice) it doesn't feel that much more complex than kotlin though [10:55]
squirrel i just wonder why google chose kotlin over scala [10:55]
cheeser it is. and while most of the advice has been "just ignore the complex parts" that's not really feasible in practice. [10:56]
cheeser scala is large and bloated and has binary compat issues. [10:56]
cheeser kotlin was designed to interop with java (in both directions) from day one. [10:56]
cheeser google "picked" kotlin, in part, because large parts of the android community were already using it anyway. [10:56]
squirrel it think java interop part in the biggest bane of kotlin. i can't quite put my finger on it but it feels like if not for that, kotlin could've been so much more different [10:58]
squirrel yeah i read about the binary compat... surely that could be mitigated though? [10:59]
cheeser to an extent. but still the on disk size was quite large. and dex has/had class size and method count limitations that are ... awkward with scala. [11:00]
squirrel huh that large [11:01]
squirrel seems that scala doesn't have a decent coroutine support either [11:03]
cheeser they're all up in the reactive game [11:04]
squirrel the website for those doesn't load [11:04]
cheeser the reactive manifesto came from the scala people [11:04]
squirrel i googled reactive and scala and i see various things... suppose i wanted to write something general-purpose coroutine-driven, what would i use? [11:12]
cheeser kotlin. :D [11:12]
squirrel hehe [11:13]
squirrel i still wish kotlin had async keyword [11:14]
cheeser it has an async *function* :D [11:14]
squirrel that's an awful function name tbh [11:14]
squirrel ok i get `launch` but `async`?? [11:15]
cheeser i usually just launch and forget. or runBlocking. [11:15]
squirrel python has this great library trio for async stuff, and i can't get over how awesome and simple their syntax and documentation is [11:16]
sec0nd [sec0nd!~second@gateway/tor-sasl/sec0nd] has joined #kotlin [11:40]
FuzzyBottom I am interested in learning C++ at some point. Is learning Kotlin a good idea to start learning programming with, or should I start with C++ and pick Kotlin up after? [11:41]
FuzzyBottom I understand after learning one, it's easier to learn others. [11:41]
cheeser start with kotlin. you're already here. :) [11:42]
FuzzyBottom That is true. I find that when I was learning C++, I felt like I was learning coding. With Kotlin, it seems like I just have to learn what function name to remember to do what I had to do manually in C++ :) [11:43]
FuzzyBottom I really enjoy Kotlin though. And minus making you angry and full of rage, I appreciate your helping me in this channel :) [11:44]