What will the code below output? Explain your answer.
console.log(0.1 + 0.2);
console.log(0.1 + 0.2 == 0.3);
(defn connected? [^SocketChannel client] | |
(or (.isConnected client) (.isOpen client))) | |
(defn get-buffer-socket | |
[^Integer port ^String address] | |
(let [client (SocketChannel/open) | |
address (InetSocketAddress. address port)] | |
(.configureBlocking client true) | |
(.connect client address) | |
(init-buffer-socket client))) |
(defn- init-buffer-socket [client] | |
(let [in-ch (async/chan) | |
out-ch (async/chan) | |
header-buf (ByteBuffer/allocate 5) | |
buff-sock (map->ByteBufferSocket {:client client | |
:in in-ch | |
:out out-ch})] | |
;; Read Backend Messages from Postgres | |
(async/go-loop [] | |
(when (connected? client) |
(ns com.clunk.buffer-socket | |
(:require [clojure.core.async :as async]) | |
(:import | |
(java.nio ByteBuffer) | |
(java.nio.channels SocketChannel) | |
(java.net InetSocketAddress))) | |
(defrecord ByteBufferSocket [^SocketChannel client in-ch out-ch]) |
/** | |
val scala3Version = "3.0.1" | |
libraryDependencies += "com.google.api-client" % "google-api-client" % "1.32.1", | |
libraryDependencies += "com.google.oauth-client" % "google-oauth-client-jetty" % "1.31.5", | |
libraryDependencies += "com.google.apis" % "google-api-services-drive" % "v3-rev197-1.25.0", | |
*/ | |
import com.google.api.services.drive._ | |
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport |
/** | |
libraryDependencies += "commons-io" % "commons-io" % "2.10.0", | |
libraryDependencies += "com.sksamuel.scrimage" % "scrimage-core" % "4.0.20", | |
libraryDependencies += ("com.sksamuel.scrimage" %% "scrimage-scala" % "4.0.20").cross(CrossVersion.for3Use2_13), | |
*/ | |
import cats.effect.{ExitCode, IO, IOApp} | |
import com.sksamuel.scrimage.ImmutableImage | |
import com.sksamuel.scrimage.nio.PngWriter | |
import java.io.File |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/react@@16/umd/react.production.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/react-dom@@16/umd/react-dom.production.min.js"></script> | |
<link | |
rel="stylesheet" | |
href="https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.css" | |
/> | |
<script src="https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.min.js"></script> |
use .base | |
use .base.Text | |
use .base.Nat | |
counter.doc = [: | |
@counter takes an `id` parameter and number `n` parameter to be incremented. | |
Prints id and number: "Counter <id>: <n>". | |
Recursively calls itself every 3 seconds with an incremented number. | |
@[signature] counter |
use .base | |
use .base.Text | |
use .base.Nat | |
counter.doc = [: | |
@counter takes an `id` parameter and number `n` parameter to be incremented. | |
Prints id and number: "Counter <id>: <n>". | |
Recursively calls itself every 3 seconds with an incremented number. | |
@[signature] counter |
def calc_steps(num): | |
count = 0 | |
while num > 1: | |
if num % 2 == 0: # bitmask: *0 | |
num = num // 2 | |
elif num == 3 or num % 4 == 1: # bitmask: 01 | |
num -= 1 | |
else: # bitmask: 11 | |
num += 1 | |
count += 1 |