Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FlapYoJacks
Feb 12, 2009

by vyelkin

(and can't post for 31 days!)

Peeny Cheez posted:

:wrong:
code:
grep -vxF a.txt b.txt > ur_mom.txt


code:
grep -vxF d.txt p.txt > ur_mom.txt

Adbot
ADBOT LOVES YOU

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Bloody posted:

:wow:

i think doing the dumb thing in c# was effectively faster for my doesnt know a unix brain but i am not surprised that it is a trivial grep
It's not the worst solution but as the files get larger it'll get poopy.

Also I forgot to put the '-f' in the example. I belong here.

Ellie Crabcakes fucked around with this message at 20:48 on Jul 26, 2018

gonadic io
Feb 16, 2011

>>=

Peeny Cheez posted:

It's not the worst solution but as the files get larger it'll get poopy.

Also I forgot to put the '-f' in the example. I belong here.

Yeah I mean for large sets you'd want to set it up properly with a hash set and for Big Data you'd do, uh, a series of smaller hash set checks applied in parallel?

Shaggar
Apr 26, 2006

Jowj posted:

ah I miss-typed. I said "why my new lines aren't triggering" and i meant my new lines of code, rather than literal new lines.

but, lol no its a loving mess. it prints out a txt file but doesn't do any standardization its a travesty.

code:
Processing server group: test

    Processing Time:
         Start: 7/26/2018 4:02:26 PM
          Stop: 7/26/2018 4:05:27 PM
       Runtime: 00 00:03:00 day(s) hr:min:sec
those are all staticly created newlines and spacing printed out. its a disgusting mess. if I had more time I would look into using an actual logging library, and making sure the application printed everything in date severity message. there are literally no time stamps other than start/stop of scan.

edit:

oh my god they are using a mix of line terminators gently caress, sometimes \n sometimes \r\n i am flabbergasted. this is windows only too.

how do you mean lines of code not triggering? if its breakpoints not being hit make sure you're in debug mode instead of release mode. release mode optimizes your code and deletes statements that it doesn't like so if you have debugging garbage it will just skip over it.

also lol good luck. if you can swing it, switching the logging to nlog or some other logging lib would absolutely be the best way to fix this.

Shaggar
Apr 26, 2006

TheCog posted:

At the risk of sounding ignorant, what is a p-lang?

perl, python, php, ruby, etc... bad Linux languages

Bloody
Mar 3, 2013

Peeny Cheez posted:

It's not the worst solution but as the files get larger it'll get poopy

yeah for sure. the problem space is limited to four text files each a hundred lines long that I wanted to gently caress around with earlier today so I feel good

Shaggar
Apr 26, 2006
the best is probably opening 2 input filestreams, 1 output filestream, and then doing copyto with an appropriate buffersize

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

TheCog posted:

At the risk of sounding ignorant, what is a p-lang?

also you’re not ignorant it’s yospos slang

gonadic io
Feb 16, 2011

>>=

Bloody posted:

yeah for sure. the problem space is limited to four text files each a hundred lines long that I wanted to gently caress around with earlier today so I feel good

are you sure the lines you're matching will be exactly identical? better spend 6 months adding a machine learning solution imo

Doom Mathematic
Sep 2, 2008

MALE SHOEGAZE posted:

also you’re not ignorant it’s yospos slang

It is? I thought it was like a mildly well-known industry term. That's how I use it at work anyway.

mystes
May 31, 2006

Doom Mathematic posted:

It is? I thought it was like a mildly well-known industry term. That's how I use it at work anyway.
Well, keep working at it and maybe it will be!

Bloody
Mar 3, 2013

gonadic io posted:

are you sure the lines you're matching will be exactly identical? better spend 6 months adding a machine learning solution imo

it doesnt take nearly 6 months to include a levenshtein library and pick an arbitrary threshold

Shaggar
Apr 26, 2006

Doom Mathematic posted:

It is? I thought it was like a mildly well-known industry term. That's how I use it at work anyway.

I think people instinctively know what you mean from context.

Shaggar
Apr 26, 2006
"we need to teach the interns how to code because they only know p-langs"
"the last idiot who worked here wrote it in some p-lang so we rewrote it in c#"

mystes
May 31, 2006

Anyway it should be real term.

I'll go make the "The pee lang is real!" hats.

VikingofRock
Aug 24, 2008




Corla Plankun posted:

can you change the doc to match the svg instead?

Nah, it's gotta match the journal template.

Honestly, remaking the flowchart in a separate doc in latex is not such a hassle, and it'll come in handy anyways as I work this into my thesis (which I am writing concurrently). I just wanted to vent a little bit because, as previously stated, "latex makes me so goddamn unreasonably mad" with how brittle it is. Thanks everyone for listening to my venting and for the suggestions.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
rats (get it, cats in rust) update: we got kleisli
code:
    #[test]
    fn test_compose_and_map() {
        let parse = kleisli::apply(|s: &str| s.parse::<i32>().map_err(|_| "parse error").lift());

        let reciprocal = kleisli::apply(|i: i32| {
            if i != 0 {
                Ok(1.0 / i as f32)
            } else {
                Err("divide by 0")
            }.lift()
        });

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(parse_and_recriprocal.run("123").unlift(), Ok(0.008130081));

        assert_eq!(
            parse_and_recriprocal.run("yospos").unlift(),
            Err("parse error")
        );

        let doubled = parse_and_recriprocal.map(|f| f * 2 as f32);
        assert_eq!(doubled.run("123").unlift(), Ok(0.016260162));
        assert_eq!(doubled.run("0").unlift(), Err("divide by 0"));
    }
if you're interested in a better explanation of kleisli than i can provide, check it: https://typelevel.org/cats/datatypes/kleisli.html


this was tricky to implement. (sorry, i know this is useless without explanation, i'm working on it).
code:
pub struct Compose<A, K1, K2> {
    k1: K1,
    k2: K2,
    marker: PhantomData<*const A>,
}

impl<'a, F, A, B, C, K1, K2, Z, G> KleisliT<'a, F, C, B, Z, G> for Compose<A, K1, K2>
where
    A: 'a,
    B: 'a,
    F: Monad<'a, F, Z, G> + 'static,
    K1: KleisliT<'a, F, A, B, Z, G>,
    K2: KleisliT<'a, F, C, A, Z, G>,
{
    fn run(&self, a: C) -> Lifted<'a, F, B, Z, G> {
        F::flat_map(self.k2.run(a), |a| self.k1.run(a))
    }
}
`Z` and `G` are unfortunate: Since we want to support HKTs of more than one type parameter, we have to pass them around everywhere when they're not being operated on. however, aside from the explosion of type parameters, it works totally fine, but I've chosen to stop at 3 parameters (or 2 parameters and another HKT for rank N types!).

side note, I wish rust would let me do this:
code:
pub struct Foo<'a,A,B,C> where A+B+C: 'a
If I want to constrain a bunch of type parameters to the same trait or lifetime bound, i should be able to do so as above. I'm going to do a little research and maybe write an RFC. unless that syntax is reserved for some other use, i cant imagine objections as it reduces a lot of syntactic noise, which is a big problem for rust.

also: i still really don't get lifetimes, and this is tied up in my complete lack of understanding around how memory works. really looking forward to digging into c/c++ because rust isn't really helping with my intuition here.

also also: translating a well-documented library from one language to another is a really useful exercise for learning.

DONT THREAD ON ME fucked around with this message at 00:23 on Jul 27, 2018

redleader
Aug 18, 2005

Engage according to operational parameters
uh, this is the terrible programmers thread. i think you're looking for the good programmers thread. easy mistake to make

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
there's nothing good about it. it's a monstrosity. i feel nothing but shame.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
for real though, i'm just reading the cats source code and re-implementing it as well as i can in rust. i love it but it's definitely not good.

thanks though

mystes
May 31, 2006

MALE SHOEGAZE posted:

rats (get it, cats in rust)
I don't know, there's got to be a dumber rust/cats pun out there somewhere. Feral?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i just happen to like rats a lot.

also i had a sweet tooth tonight, so check out this sweet sweet syntactic sugar:

code:
/// Lifts a funtion Fn(A) -> L into a Kleisli where L implement Lift
pub fn lift<'a, F, A, B, Z, G, L>(run: impl Fn(A) -> L + 'a) -> impl Kleisli<'a, F, A, B, Z, G>
where
    L: Lift<'a, F, B, Z, G> + 'a,
    F: 'static,
    G: 'static,
    B: 'a,
    Z: 'a,
{
    self::run(move |a| run(a).lift())
}

/// Evaluate the Kleisli with A, and unlift the resulting Lifted
fn runlift(&self, a: A) -> <Lifted<'a, F, B, Z, G> as Unlift<F>>::Out
    where
    Lifted<'a, F, B, Z, G>: Unlift<F>,
    {
        Kleisli::<_, _, _, _, _>::run(self, a).unlift()
    }

    // and now the earlier example works without having to explicitly lift and unlift everything:  
    // (ok it's still explicit but a lot nicer)
    #[test]
    fn test_compose_and_map() {
        let parse = kleisli::lift(|s: &str| s.parse::<i32>().map_err(|_| "parse error"));

        let reciprocal = kleisli::lift(|i: i32| {
            if i != 0 {
                Ok(1.0 / i as f32)
            } else {
                Err("divide by 0")
            }
        });

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(parse_and_recriprocal.runlift("123"), Ok(0.008130081));

        assert_eq!(parse_and_recriprocal.runlift("yospos"), Err("parse error"));

        let doubled = parse_and_recriprocal.map(|f| f * 2 as f32);
        assert_eq!(doubled.runlift("123"), Ok(0.016260162));
        assert_eq!(doubled.runlift("0"), Err("divide by 0"));
    }

Luigi Thirty
Apr 30, 2006

Emergency confection port.

MFC is real bad lmao

I will stick with C calls

tinaun
Jun 9, 2011

                  tell me...

MALE SHOEGAZE posted:

side note, I wish rust would let me do this:
code:
pub struct Foo<'a,A,B,C> where A+B+C: 'a
If I want to constrain a bunch of type parameters to the same trait or lifetime bound, i should be able to do so as above. I'm going to do a little research and maybe write an RFC. unless that syntax is reserved for some other use, i cant imagine objections as it reduces a lot of syntactic noise, which is a big problem for rust.

male shoegaze i think the inferred outlives rfc and the implied bounds rfc would help you out here and cover most of what you want. (it won't hurt to submit your rfc though, it doesn't seem like that large of an addition). there's also an ancient rfc about lifetime elision in impl headers that was accepted pre 1.0 and only now getting around to being implemented.

once these are implemented you wouldn't need to copy your lifetime requirements on every function and impl block that acts on the same types and it would reduce a lot of noise.

tinaun fucked around with this message at 06:12 on Jul 27, 2018

gonadic io
Feb 16, 2011

>>=

mystes posted:

I don't know, there's got to be a dumber rust/cats pun out there somewhere. Feral?

Rascall

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

TheCog posted:

At the risk of sounding ignorant, what is a p-lang?

I don’t know, what’s a p-lang with you?

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


eschaton posted:

I don’t know, what’s a p-lang with you?

pos-lang

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

eschaton posted:

I don’t know, what’s a p-lang with you?
You Dane Cook motherfucker

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Luigi Thirty posted:

MFC is real bad lmao

I will stick with C calls
Have you tried Cw MC Calls?

vanity slug
Jul 20, 2010

TheCog posted:

At the risk of sounding ignorant, what is a p-lang?

p-lang is stored in the balls

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


MALE SHOEGAZE posted:

i just happen to like rats a lot.

also i had a sweet tooth tonight, so check out this sweet sweet syntactic sugar:

code:
/// Lifts a funtion Fn(A) -> L into a Kleisli where L implement Lift
pub fn lift<'a, F, A, B, Z, G, L>(run: impl Fn(A) -> L + 'a) -> impl Kleisli<'a, F, A, B, Z, G>
where
    L: Lift<'a, F, B, Z, G> + 'a,
    F: 'static,
    G: 'static,
    B: 'a,
    Z: 'a,
{
    self::run(move |a| run(a).lift())
}

/// Evaluate the Kleisli with A, and unlift the resulting Lifted
fn runlift(&self, a: A) -> <Lifted<'a, F, B, Z, G> as Unlift<F>>::Out
    where
    Lifted<'a, F, B, Z, G>: Unlift<F>,
    {
        Kleisli::<_, _, _, _, _>::run(self, a).unlift()
    }

    // and now the earlier example works without having to explicitly lift and unlift everything:  
    // (ok it's still explicit but a lot nicer)
    #[test]
    fn test_compose_and_map() {
        let parse = kleisli::lift(|s: &str| s.parse::<i32>().map_err(|_| "parse error"));

        let reciprocal = kleisli::lift(|i: i32| {
            if i != 0 {
                Ok(1.0 / i as f32)
            } else {
                Err("divide by 0")
            }
        });

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(parse_and_recriprocal.runlift("123"), Ok(0.008130081));

        assert_eq!(parse_and_recriprocal.runlift("yospos"), Err("parse error"));

        let doubled = parse_and_recriprocal.map(|f| f * 2 as f32);
        assert_eq!(doubled.runlift("123"), Ok(0.016260162));
        assert_eq!(doubled.runlift("0"), Err("divide by 0"));
    }

what the gently caress sort of moon language is this

cinci zoo sniper
Mar 15, 2013




cjs: if only our programmers had some means to work around the problem of excel’s xirr formula not being included in php standard library

gonadic io
Feb 16, 2011

>>=

Powerful Two-Hander posted:

what the gently caress sort of moon language is this

It started as rust, which has syntax not dissimilar from c++. It is now something very different however

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Powerful Two-Hander posted:

what the gently caress sort of moon language is this
Male Shoegaze has drunk deeply of the FP Kool-Aide

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
does rust let you declare your own operators, using Unicode too?

because if not, there’s a project for shoegaze

get all APL up in here

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
the FP people need more APL in their lives

gonadic io
Feb 16, 2011

>>=

eschaton posted:

does rust let you declare your own operators, using Unicode too?

because if not, there’s a project for shoegaze

get all APL up in here

https://github.com/rust-lang/rfcs/issues/818

quote:

I'm closing this RFC as most people seem to be aganist this idea. I admit that in general the usefulness of this feature is limited. I was writing parser combinators which is one of the few times custom operators could be useful.

jony neuemonic
Nov 13, 2009

eschaton posted:

the FP people need more APL in their lives

as do we all.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Peeny Cheez posted:

Have you tried Cw MC Calls?

booooooo

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

tinaun posted:

male shoegaze i think the inferred outlives rfc and the implied bounds rfc would help you out here and cover most of what you want. (it won't hurt to submit your rfc though, it doesn't seem like that large of an addition). there's also an ancient rfc about lifetime elision in impl headers that was accepted pre 1.0 and only now getting around to being implemented.

once these are implemented you wouldn't need to copy your lifetime requirements on every function and impl block that acts on the same types and it would reduce a lot of noise.

oooh yeah these would help a lot. as you said though, my suggestion seems harmless so i might give it a shot just for fun.

completely unrelated question because i'm pretty sure i saw your name on the futures 0.3 pr: my "lifting" works fine with futures 0.1 and futures 0.2, but sadly doesn't work with the new stdlib futures in nightly because they aren't object safe as they're using arbitrary self types. Do you have any idea if there are plans to lift the restrictions on object safety to allow arbitrary self types or if some other workaround is planned? I really want to put these futures in a box. nm i just googled it and yes: they're working on it.




eschaton posted:

does rust let you declare your own operators, using Unicode too?

because if not, there’s a project for shoegaze

get all APL up in here
oh man as someone who has experienced scala first hand: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. the only good custom scala operator i've encountered is `===`, which is good because the builtin equals is very bad. as much as i'm enjoying FP concepts i really don't like operator soup.

otoh, adding custom operators would be in keeping with my previous terrible programming language contribution: adding nested ternary expressions to Crystal.

Peeny Cheez posted:

Male Shoegaze has drunk deeply of the FP Kool-Aide

i know you're just poking fun but let me just state that I am not an FP zealot. It's really fun and it's making my brain grow and I'll definitely continue to apply a lot of these concepts to other things, but I don't think it's the best/only way to program. I just came off a year at a scala shop and I didn't get to explore these concepts as much as I wanted so here I am.

Powerful Two-Hander posted:

what the gently caress sort of moon language is this

it's good

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply