| 00:39:29 | * | beholders_eye quit (Ping timeout: 245 seconds) |
| 00:39:29 | FromDiscord | <zillikescoding> hey guys |
| 00:39:31 | FromDiscord | <zillikescoding> @here |
| 00:39:38 | FromDiscord | <zillikescoding> how did all of you learn nim |
| 00:39:47 | FromDiscord | <zillikescoding> i litterly just known about it and i want to learn it |
| 00:41:01 | nmz | aintea, do you know any solutions to my problem? |
| 00:42:09 | FromDiscord | <aintea> Your last message was "AYe" which I didn't really understand |
| 00:42:20 | nmz | uhh |
| 00:42:25 | FromDiscord | <aintea> I understand you're trying to remake a sed command |
| 00:42:27 | nmz | aye means yeah |
| 00:42:36 | FromDiscord | <aintea> but I'm not sure exactly on what feature you're having issues |
| 00:42:47 | FromDiscord | <aintea> I asked you "what issue do you have" and you answered "AYe" |
| 00:42:49 | FromDiscord | <zillikescoding> In reply to @aintea "but I'm not sure": howd you learn nim? |
| 00:42:56 | FromDiscord | <zillikescoding> im jsut really curios |
| 00:42:59 | nmz | in court for example, whenever a voting happens, congressman say "aye" or "nay" which means yes or no |
| 00:43:00 | FromDiscord | <zillikescoding> i just knew about the laungage |
| 00:43:16 | FromDiscord | <aintea> The nim book, Nim Days, Learn Nim in Y minutes |
| 00:43:21 | FromDiscord | <aintea> and practicing with advent of code |
| 00:43:23 | FromDiscord | <zillikescoding> thx |
| 00:43:29 | FromDiscord | <zillikescoding> In reply to @nmz "in court for example,": why are you a app? |
| 00:43:32 | FromDiscord | <zillikescoding> but talk like a human |
| 00:43:36 | nmz | its a very common word |
| 00:43:43 | FromDiscord | <aintea> In reply to @nmz "in court for example,": you answered "yes" when I asked what the exact problem was |
| 00:43:49 | FromDiscord | <aintea> Which is a bit confusing lmao |
| 00:46:31 | nmz | Welp... |
| 00:46:35 | nmz | anyway |
| 00:46:39 | nmz | is there an answer? |
| 00:47:02 | FromDiscord | <aintea> At the moment I don't understand your exact problem, so I'd say no |
| 00:47:11 | FromDiscord | <aintea> sorry |
| 00:47:14 | nmz | oh, are you a windows user? |
| 00:47:33 | nmz | now I notice that windows users don't know sed |
| 00:48:23 | nmz | for line in stdin.lines: echo line -> This adds an extra newline at the end |
| 00:48:50 | nmz | * this code is wrong because it adds an extra newline at the end |
| 00:48:56 | nmz | So I'm trying to fix that code |
| 00:51:23 | FromDiscord | <aintea> You'd have two solutions |
| 00:51:54 | FromDiscord | <aintea> Either use a for loop with an int and then check if it's the last line printed, if not add a newline↵↵Or make your list of lines as string in advance and join it with '\n' |
| 00:52:58 | FromDiscord | <aintea> for example |
| 00:53:30 | FromDiscord | <aintea> sent a code paste, see https://play.nim-lang.org/#pasty=yOkZjvMD |
| 00:55:46 | FromDiscord | <aintea> sent a code paste, see https://play.nim-lang.org/#pasty=UFsYvtqG |
| 00:58:12 | FromDiscord | <aintea> this way, no added extra line at the end |
| 00:59:46 | nmz | what the |
| 01:00:26 | nmz | no, that's not it either |
| 01:01:10 | nmz | that's really redundant, write line already writes the line without any need for looping |
| 01:05:14 | nmz | now I'm not understanding you, ha |
| 01:05:23 | nmz | anyway, I give up, I'll just stick to sed |
| 01:06:08 | FromDiscord | <nasuray> In reply to @nmz "anyway, I give up,": Do you care if the whole file is ready into memory? |
| 01:06:14 | nmz | I do |
| 01:07:10 | nmz | else I would've readall and just replaced all \n with "\n " |
| 01:07:30 | nmz | which isn't a bad idea, but that wouldn't be better than sed or the C version |
| 01:11:19 | FromDiscord | <nasuray> In reply to @nmz "else I would've readall": So you want to ignore a newline if it's in the final position though? May require checking the cursor position on a file object |
| 01:12:20 | FromDiscord | <nasuray> Or do a two pass iteration and track the line number |
| 01:25:30 | * | ftajhii joined #nim |
| 01:34:32 | * | gabreal joined #nim |
| 01:35:24 | * | gabreal quit (Client Quit) |
| 01:37:32 | * | rockcavera quit (Remote host closed the connection) |
| 01:44:41 | nmz | I don't want to ignore the newline, that's the point, I want to edit a single line, without changing all other lines. |
| 01:44:48 | nmz | or the last line |
| 01:51:24 | nmz | basically stdout.write( stdin.readall() ) does the right thing, but now you have to watch out for memory, so doing it iteratively is a better deal |
| 01:51:47 | nmz | Can you check the cursor position on stdin? |
| 02:25:16 | FromDiscord | <aintea> afaik stdin is like a stream, you don't know how much you still have to read except if you put all of stdin into a buffer |
| 02:32:04 | * | mrinsane quit (Ping timeout: 268 seconds) |
| 02:34:41 | FromDiscord | <nasuray> Don't know about cursor position on stdin but it's a File https://github.com/nim-lang/Nim/blob/b8e13bd421d37c3f06c59a5ac5c50e051785ad9d/lib/std/syncio.nim#L67 |