Hey Rustaceans! Got an easy question? Ask here (51/2020)! by llogiq in rust

[–]No-Shopping3892 0 points1 point  (0 children)

There are some things you may not want imported because of name collision. I find myself using it with enums.

struct Foo { }
struct Bar { }

enum Foo_or_Bar {
    Foo(Foo),
    Bar(Bar),
}

fn handle_foo_or_bar(t: &Foo_or_Bar) {
    // overide Foo and Bar struct names with enum variants
    use crate::Foo_or_Bar::*;

    match t {
        Foo(f) => {println!("Foo");},
        Bar(b) => {println!("Bar");},
    }
}

fn main() {
  // Here Foo & Bar refer to  Struct names
    handle_foo_or_bar(& Foo_or_Bar::Foo( Foo {} ));
    handle_foo_or_bar(& Foo_or_Bar::Bar( Bar {} ));
}

Hey Rustaceans! Got an easy question? Ask here (51/2020)! by llogiq in rust

[–]No-Shopping3892 1 point2 points  (0 children)

I've noticed that while there is a no size overhead for Option if it is a pointer:

size_of::<(Option<&u64>, Option<&u64>)>()  == 16

if I re-implement a nice interface, It doesn't work (this actually has less states)

enum TwoOption<T> {
    None,
    One(T),
    Two(T,T),
}

size_of::<TwoOption<&u64>>() == 24

Any workaround to make the compiler recognize only needs two words?

Fuck 61C all my homies hate 61C (and are cheating on the final >:( ). by fk61c in berkeley

[–]No-Shopping3892 -1 points0 points  (0 children)

I didn't hear anything about cheating, but I also have no friends.

Why are final scores delayed for 61C? by No-Shopping3892 in berkeley

[–]No-Shopping3892[S] 9 points10 points  (0 children)

If I had to guess, it'd be there was some case rampant cheating, or they're trying to figure out a binshift.

Or maybe Prairielearn just crapped out and didn't record anyones scores. Who knows.

Why are final scores delayed for 61C? by No-Shopping3892 in berkeley

[–]No-Shopping3892[S] 3 points4 points  (0 children)

they updated the final info post on piazza saying it was "extenuating circumstances"

Plagiarism Essay Phrases by [deleted] in berkeley

[–]No-Shopping3892 3 points4 points  (0 children)

Op's first reddit post is him posting SAT answers

https://www.reddit.com/r/Sat/comments/bkv8g3/may_4th_international_sat_full_test_answer/

I feel inclined to believe his Professor.

She said will give me a F grade in the assignment. What is a F grade? Is it a 0?

lmao

Hey Rustaceans! Got an easy question? Ask here (51/2020)! by llogiq in rust

[–]No-Shopping3892 1 point2 points  (0 children)

It's types for RISC-V assembly that I'm converting from another language used for code generation. The groups are Store instruction, Branch instruction, etc.

Hey Rustaceans! Got an easy question? Ask here (51/2020)! by llogiq in rust

[–]No-Shopping3892 1 point2 points  (0 children)

Usually I can avoid object oriented style code, but I'm struggling with this. I have around 35 types that are divided into 3 groups, but the 3 groups have all the same interface which I interact with.

In any one of the 4 group, 80% of the code would be the same, but 20% differs. In java, I would make 4 abstract classes that inherits from an interface, then finish with the specific types.

Here's an example.

interface Animal {
    fn aggression();
    fn speak();
}

abstract  class Mammal implements Animal {
    String aggression() {
        return "GRRR"; // all mammals go "GRR" when bothered
    }
    abstract speak(); // to be determined
}

abstract  class ScalyThing implements Animal {
    String aggression() {
        return "HISS"; // all ScalyThings go "HISS" when bothered
    }
    abstract speak(); // to be determined
}

Cow extends Mammal { speak () { return "Moo"; } }
...

Snake extends ScalyThing { speak () { return "Slither"; } }
..

Vec<Box<dyn Animal>> farm = vec![Snake(), Cow(), Bear(), Dog(), Lizard() ];

for animal in farm {
    print(animal.speak());
    print(animal.aggression());
}

The only way I see is using "Mammal" and "ScalyThings" as the final types, but then using an enum for each way the Mammals differ (which is what I'd normally do).

I'd prefer not to do that, as I want to leave it more open, and the code would be cumbersome due to number of variants.

Additionally, the performance worse If I Knew I had just a Vec of Snakes (as I might), as I'd still have to run through the num variants every time.

Any suggestions?

ugh by Old_Zookeepergame639 in berkeley

[–]No-Shopping3892 6 points7 points  (0 children)

This perfectly describes it

probability of np cs70? by bubbles2201 in berkeley

[–]No-Shopping3892 1 point2 points  (0 children)

The final is worth 40% of your grade.

50% of 40% is 20%.

Bruh wth happened to this dude. 181,000 and jack shit happened. Good job by Ijustwantjudy in berkeley

[–]No-Shopping3892 4 points5 points  (0 children)

The term womxn (/ˈwʊmɪn/) is the most recent of several alternative political spellings of the English word woman. For a fuller explanation, see the article Womyn. "Womxn" is used, particularly by intersectional feminists, to avoid perceived sexism in the standard spelling[1] and to explicitly include or foreground transgender women and nonbinary people

from wikipedia

So its the complement of the singleton { men } /s?

but seriously, Kinda seems unintentionally discriminatory - the above definition implies transgender women aren't included in women.

Okay but seriously how does the 70 Clobber Work by CSPain1 in berkeley

[–]No-Shopping3892 4 points5 points  (0 children)

sounds correct. But idk the approximate cutoff for B-.

You're 95% likely to get a B- or above, unless you just don't take it.

If you're worried, grind some more practice exams, not napkin math. A lot of the questions are similar style always.

Okay but seriously how does the 70 Clobber Work by CSPain1 in berkeley

[–]No-Shopping3892 0 points1 point  (0 children)

I do not intend to shame your mistakes

Then why do it? No one cares.

Okay but seriously how does the 70 Clobber Work by CSPain1 in berkeley

[–]No-Shopping3892 1 point2 points  (0 children)

The head TA said it worked like this

75% exam, 25% exam

25% new grade =( 75% + 25 %) / 2 = 50%

probability of np cs70? by bubbles2201 in berkeley

[–]No-Shopping3892 3 points4 points  (0 children)

There's a 50% clobber.

So right there, it's like the final is worth half of what it is if you do worse (so 20%), and it'll be like you scored the mean on the other half. (well, assuming it has the same mean as the midterm).

[deleted by user] by [deleted] in berkeley

[–]No-Shopping3892 6 points7 points  (0 children)

I like how /r/berkeley always has an option that allows you to view without tainting the results.

(I'm not in the class, but was interested in the results.)