18107

joined 2 years ago
[–] [email protected] 6 points 3 weeks ago* (last edited 3 weeks ago)

I decided to use NAND instead of NOR, but it's effectively the same thing.

Scala:

//main
@main
def main(): Unit =
  var i = 15 //Choose any number here
  i = add(i, 1) //this increments i
  println(i)

//Adds 2 numbers in the most intuitive way
def add(a: Int, b: Int): Int =
  val pairs = split(a).zip(split(b))
  val sumCarry = pairs.scanLeft(false, false)((last, current) => fullAdder(current._1, current._2, last._2))
  return join(sumCarry.map(_._1).tail.reverse)

//Converts an integer to a list of booleans
def join(list: Seq[Boolean]): Int = BigInt(list.map(if (_) '1' else '0').mkString, 2).toInt

//Converts a list of booleans to an integer
def split(num: Int): Seq[Boolean] = num.toBinaryString.reverse.padTo(32, '0').map(_ == '1')

//Adds 2 booleans and a carry in, returns a sum and carry out
def fullAdder (a: Boolean, b: Boolean, c: Boolean): (Boolean, Boolean) =
  (NAND(NAND(NAND(NAND(a, NAND(a, b)), NAND(NAND(a, b), b)), NAND(NAND(NAND(a, NAND(a, b)), NAND(NAND(a, b), b)), c)), NAND(NAND(NAND(NAND(a, NAND(a, b)), NAND(NAND(a, b), b)), c), c)), NAND(NAND(NAND(NAND(a, NAND(a, b)), NAND(NAND(a, b), b)), c), NAND(a, b)))

//The basis for all operations
def NAND(a: Boolean, b: Boolean): Boolean = !a || !b

EDIT: replaced Integer.parseInt with BigInt(...).toInt to fix NumberFormatException with negative numbers.

try it online here

 
[–] [email protected] 35 points 1 month ago
  1. Put on gorilla suit
  2. Teleport to the ISS for the second time
[–] [email protected] 10 points 2 months ago* (last edited 2 months ago)

LocalSend. File transfer between any devices with (almost) any OS over LAN. No account required. The best file transfer app I've ever encountered by far.

StreetComplete. Get motivated to go outside with quests to help complete OpenStreetMaps. Surprisingly addictive. Requires an OpenStreetMaps account.

f.lux. Remove the blue light from your computer monitor in the evening to help you fall asleep more easily. Redshift. As above. Not quite as good, but works on some OS/System configurations that f.lux can't handle.

Pulsar. A community version of the discontinued Atom text editor. Highly extendable and configurable. Great for small programming tasks or opening text files with an obscure syntax. Has most of the packages built for Atom.

Home Assistant. For automating your house and more (controlling smart lights and appliances, monitoring solar panel output, weather forecasts, printer diagnostics, delivery tracking...). A dedicated device (Raspberry Pi, old laptop) is highly recommended. A bit of a learning curve, but hard to live without after using it.

[–] [email protected] 22 points 1 year ago

They were possibly confusing nitrogen with carbon dioxide. CO2 will definitely lead to distress in high concentrations, and has been used in some slaughterhouses.

[–] [email protected] 1 points 1 year ago

What's the charging efficiency?

[–] [email protected] 7 points 1 year ago

Most electric cars only have 1 gear and it's always engaged. If you put the car in reverse, it uses the same gear, but the motor spins the other way.

Even in neutral the motor still spins when the wheels are turned, it just doesn't output any power to the wheels.

[–] [email protected] 12 points 1 year ago

She looks very polite.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

There is a difference between climate concern, where you desperately want to do anything to fix the climate problems, and climate anxiety, where you are so overwhelmed by the climate issues that it interferes with your ability to take any action.

I suspect this study is focusing only on the latter.

[–] [email protected] 15 points 1 year ago (11 children)

Most Russian people have committed no crime, and many do not support what their leader has done. We should not condem people for the country they were born in.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

I have used Kagi for several weeks and can't go back. I can finally find things on the internet again and I don't want to lose that again.

[–] [email protected] 2 points 1 year ago (2 children)

If you don't mind paying to use a search engine, Kagi is actually pretty good. Not as good as Google was 20 years ago, but significantly better than any other search engine I can find today.

[–] [email protected] 1 points 1 year ago

Interesting extension. I think I'll give it a try.

It is entirely open source, and the website does a very good job explaining what it does and why.

 

I use it to heat my house.

 

But at least you're not one of the people getting on a ship.

 

It only lasts for 12 months out of the year.

I was trying to ask my partner for a pbj sandwich. I accidentally asked for a beef sandwich, then tried to describe the sandwich as boneless and without the meat.

I eventually reached apricot marmalade, which was close enough for my partner to understand the request.

 

I've been logging my headaches since I started taking Eletriptan in 2020.

I've had an average of 10 days per month with headaches, and 4 days per month with migraines.

So far I've identified stress and insufficient sleep as contributing factors.

 

As far as I'm aware, these 2 communities should be kept identical by federation. The first link shows 4 posts, but the second link shows 0 posts.
What could be done to fix this?

https://lemmy.ml/c/nissan_leaf
https://aussie.zone/c/[email protected]

view more: next ›