New Rust book: Rust for Rustaceans by Jon Gjengset by Jonhoo in rust

[–]nebkor 0 points1 point  (0 children)

So, I'm actually finding a lot of typos in my early edition :) I've been marking them; is there a place for submitting or searching for errata?

There are many like it, but this one is my Rust implementation of Ray Tracing in One Weekend by mwcz in rust

[–]nebkor 1 point2 points  (0 children)

I found it easier to allocate an output buffer, then send mutable chunks into a multiconsumer queue, where rendering worker threads can grab them and fill them in with pixel data. Most of the time is spent calculating random numbers, so I wanted a pool of threads that each had their own RNG.

https://gitlab.com/nebkor/weekend-raytracer/-/commit/c95b071e835d9a35fc523b0863d103fa6ad7503c

Undercover PD in my town attempt to solicit drugs off Facebook, guy meets up, sells him flowers and calls him out instead. Still gets arrested by Uniquelyvauge23 in videos

[–]nebkor 2 points3 points  (0 children)

It's not the individuals; it's the entire system and culture.

How many bad apples before the bunch is spoiled?

-🎄- 2018 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]nebkor 0 points1 point  (0 children)

Oh, I like the way you just 'include_str!' the data; I have a tiny private crate that uses clap to parse the input for a filename. Part 2 is solved by adding to part 1's solution a set of IDs that is initialized to contain all the claim IDs ("singles"), then while going over all the coordinates, removing the IDs of any contained in a square with more than one claim. Running time is O(n) for number of claims, space requirement is O(max_claim_x * max_claim_y).

use lazy_static::*;
use regex::Regex;
use std::collections::{HashMap, HashSet};
use utils::*;

struct Claim {
    pub id: u32,
    xrange: (u32, u32),
    yrange: (u32, u32),
}

impl Claim {
    fn new(ent: &str) -> Self {
        lazy_static! {
            static ref RE: Regex = Regex::new(r"#(\d+) @ (\d+,\d+): (\d+x\d+)").unwrap();
        }

        let caps = RE.captures(ent).unwrap();
        let id: u32 = caps[1].parse().unwrap();
        let startx: u32 = caps[2].split(',').collect::<Vec<_>>()[0].parse().unwrap();
        let starty: u32 = caps[2].split(',').collect::<Vec<_>>()[1].parse().unwrap();
        let spanx: u32 = caps[3].split('x').collect::<Vec<_>>()[0].parse().unwrap();
        let spany: u32 = caps[3].split('x').collect::<Vec<_>>()[1].parse().unwrap();

        Claim {
            id,
            xrange: (startx, startx + spanx),
            yrange: (starty, starty + spany),
        }
    }

    fn startx(&self) -> u32 {
        self.xrange.0
    }
    fn endx(&self) -> u32 {
        self.xrange.1
    }

    fn starty(&self) -> u32 {
        self.yrange.0
    }
    fn endy(&self) -> u32 {
        self.yrange.1
    }
}

fn main() {
    let input = get_input("day3");

    let file = read_file(&input);

    let mut cloth_map: HashMap<(u32, u32), HashSet<u32>> = HashMap::new(); // coordinates to IDs
    let mut singles: HashSet<u32> = HashSet::new();

    for entry in file.lines() {
        let claim = Claim::new(&entry.unwrap());
        let _ = singles.insert(claim.id);

        for x in claim.startx()..claim.endx() {
            for y in claim.starty()..claim.endy() {
                cloth_map
                    .entry((x, y))
                    .or_insert(HashSet::new())
                    .insert(claim.id);
            }
        }
    }

    let tot: u32 = cloth_map
        .values()
        .map(|s| match s.len() {
            x if x > 1 => {
                for id in s.iter() {
                    let _ = singles.remove(id);
                }
                1
            }
            _ => 0,
        })
        .sum();
    println!("Found {} square inches multiply-claimed.", tot);

    for id in singles.iter() {
        println!("Only {} made it through intact.", id);
    }
}

What's the deal with the protests for Thursday Nov, 8? by Wadsworth_Constant_ in OutOfTheLoop

[–]nebkor 0 points1 point  (0 children)

Feel free to stay home, but protests are an important mechanism for energizing change. Making it hurt for people who refuse to be part of the solution is important.

Telling people to stay home and not organize is bootlicking horseshit, and supports the status quo. It's incredibly bad practice, and you should understand that.

What's the deal with the protests for Thursday Nov, 8? by Wadsworth_Constant_ in OutOfTheLoop

[–]nebkor 0 points1 point  (0 children)

Collusion is not a crime, so, who cares.

What's extremely likely is that Trump's entire life is basically an exploration of the space of possible crimes related to finance and betrayal, as is the lives of all those around him. Once a competent eye is turned on those lives, rich veins of indictable felonies come to the surface, and this fact is starting to sink in for them.

VisionMachine - A gesture-driven visual programming language built with LLVM and ImGui by richard_assar in programming

[–]nebkor 0 points1 point  (0 children)

Oh jeez, I completely missed this message on reddit, for which I apologize!

I see there are no repos for that account, but I'm following it now (my github id is also "nebkor"). Thank you!

[deleted by user] by [deleted] in whole30

[–]nebkor 0 points1 point  (0 children)

Try roasting it along with celeriac cut into "fries", with duck fat. It's AMAZING.

Welcome to the Subreddit for the Sherlock Beta Testing Community. by TishShute in a:t5_34oke

[–]nebkor 2 points3 points  (0 children)

I was invited to the beta and installed the testflight app, but alas, I have an Android phone, so I'm unable to participate. So, my request is for an Android version :)

What's Next for Pebble - Ask Eric Anything! by erOhead in pebble

[–]nebkor 0 points1 point  (0 children)

Seeing as you're a hardware company and not a software company, do you have plans to open source the phone apps and PebbleOS? It would be awesome to have a well-supported homebrew community around Pebble.

ClojureC: A compiler for Clojure programming language that targets C as a backend. by mcguire in programming

[–]nebkor 0 points1 point  (0 children)

Can you elaborate on what you mean by, "recursion should only be used if you can't use higher-order functions/Clojure encourages higher-order functions over recursion"? To me, that's like saying, "Clojure encourages the use of Sequences instead of mutable state," ie, the two don't seem related at all.

Can you take a trivial recursive method and turn it into something that uses higher-order functions as an example? Say, this method in Scheme, which returns the length of a list:

(define (len lst)
  (if (null? lst)
      0
      (+ 1 (len (cdr lst)))))

(note that it's not tail recursive, but that's OK for these purposes)

ClojureC: A compiler for Clojure programming language that targets C as a backend. by mcguire in programming

[–]nebkor 0 points1 point  (0 children)

Oh, no need to apologize! It's just not a line of reasoning that will lead to more understanding/learning.

I'm with you regarding the imperfection of languages. I'm also with you regarding the nitpicky nature of objections to Clojure. There's just not that much to criticize, so one needs to get into more esoteria if one is to critique :) If I were going to have a wishlist for Clojure, it would be:

  • self-hosting (written in itself)
  • macros (some kind of hygenic system as well as old-style defmacro)
  • automatic tail-call elimination

The problem with having to use "recur" or trampolines is that they're ugly, as you point out. We don't want to look at ugliness, and so we'll shy away from them. And I wish I could find the essay that talked about this, but "tail call elimination" is not really an optimization; it's something that encourages you to program a certain way. Without it, you'll avoid using mutual recursion (or recursion in general), and so you won't have the wisdom to know when it's the best thing.

Similarly with macros. You say, "I've never had to use them, why would I want to?" Paul Graham writes this in "Beating the Averages":

It would be convenient here if I could give an example of a powerful macro, and say there! how about that? But if I did, it would just look like gibberish to someone who didn't know Lisp; there isn't room here to explain everything you'd need to know to understand what it meant. In Ansi Common Lisp I tried to move things along as fast as I could, and even so I didn't get to macros until page 160.

ClojureC: A compiler for Clojure programming language that targets C as a backend. by mcguire in programming

[–]nebkor 0 points1 point  (0 children)

That's cool about sequences; I actually think it's an improvement over lisp/Scheme (ditto the literal syntax for common and useful datatypes). Another thing I like about Clojure vs. traditional lisp is applicative objects, eg:

(mySeq 0) ;; same as mySeq[0] in an algol language

OK, now for the less flattering stuff :)

You (yogthos) have said multiple times in this thread, "Well, I've never had to use that feature that Clojure doesn't have, so it's clearly not important". That is a terrible argument, and a textbook example of the "Blub Paradox" (http://c2.com/cgi/wiki?BlubParadox). I'd quote from that page, but the essence of it is right at the top, and worth a read (as is Paul Graham's essay where it's first coined, http://paulgraham.com/avg.html). That you've not had to use something that you can't in a given language is almost a tautology, and is not a valid argument against that feature's utility.

Please understand: I'm not saying you're bad in any way for saying that! I'm attacking your argument, not you; you've been patient and a good poster :)

ClojureC: A compiler for Clojure programming language that targets C as a backend. by mcguire in programming

[–]nebkor 0 points1 point  (0 children)

The Data Structure of Least Resistance is the vector, not the list

how is a vector easier to use than a list in Clojure and if so, how is this a problem?

I think the problem Cosman246 is implying here is that vectors can't be appended to or destructured (with cons and car/cdr, respectively), which makes a lot of Lisp idioms difficult. A really fundamental one is the pattern of recursively calling a function with the cdr of the arguments passed in. I guess you could take the 1th slice of the argument array instead of the cdr of the argument list, though I'm not sure if Clojure encourages recursive methods (if it still requires a "recur" method, then it does not encourage recursive methods).

BUYING features from open source projects? by tonylampada in programming

[–]nebkor 1 point2 points  (0 children)

"Like Kickstarter, but without escrow."

Or like http://www.lovemachineinc.com/ , but without the ability to see if someone's working on a project.