• 0 Posts
  • 30 Comments
Joined 1 year ago
cake
Cake day: August 23rd, 2023

help-circle


  • Please remember that this particular groyper meme is a literal copy of a Trump 2016 meme with the word “Trump” replaced with “Biden” and was deployed regularly by the alt-right. Please keep that in context while you give the argument that its in a totally different context. Its like responding to dog whistling accusations with more dog whistling.










  • He hasn’t been sentenced yet and won’t be for months. Its possible that he won’t be sentenced until after the election. He’s also been indicted for paying the porn star, Stormy Daniels, hush money.

    So, out-of-context, its just another rich dude doing money crime in the US. Its not like he’s been convicted of being a russian asset or doing war crimes. Convention is to give him a slap on the wrist. But external political pressures and him being a unique dumbass to the judge will probably result in a tougher sentencing. But I doubt there will be any prison time, even white collar.

    Also you cans still run for president from prison. Eugene V. Debs ran as the Socialist Party candidate while jailed for sedition during WWI.








  • Very standard use case for a fold or reduce function with an immutable Map as the accumulator

    val ints = List(1, 2, 2, 3, 3, 3)
    val sum = ints.foldLeft(0)(_ + _) // 14
    val counts = ints.foldLeft(Map.empty[Int, Int])((c, x) => {
      c.updated(x , c.getOrElse(x, 0) + 1)
    })
    

    foldLeft is a classic higher order function. Every functional programming language will have this plus multiple variants of it in their standard library. Newer non-functional programing languages will have it too. Writing implementations of foldLeft and foldRight is standard for learning recursive functions.

    The lambda is applied to the initial value (0 or Map.empty[Int, Int]) and the first item in the list. The return type of the lambda must be the same type as the initial value. It then repeats the processes on the second value in the list, but using the previous result, and so on until theres no more items.

    In the example above, c will change like you’d expect a mutable solution would but its a new Map each time. This might sound inefficient but its not really. Because each Map is immutable it can be optimized to share memory of the past Maps it was constructed from. Thats something you absolutely cannot do if your structures are mutable.