instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package japgolly.scalajs.react.extra.router2 sealed trait RouteCmd[A] object RouteCmd { /** * Pushes the given data onto the session history stack with the specified title and, if provided, URL. */ case class PushState(url: AbsUrl) extends RouteCmd[Unit] /** * Updates the most recent entry on the his...
Explain and rewrite the following Scala code:
/* * Copyright 2016 Actian Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
Explain and rewrite the following Scala code:
package mesosphere.marathon.state trait Timestamped { val version: Timestamp } object Timestamped { /** * Returns an ordering on type `T` derived from the natural ordering of * the `T`'s timestamps. */ def timestampOrdering[T <: Timestamped](): Ordering[T] = Ordering.by { (item: T) => item.version }...
Explain and rewrite the following Scala code:
package de.frosner.broccoli.instances.storage.filesystem import java.io._ import java.nio.file._ import java.util.UUID import com.fasterxml.jackson.core.JsonParseException import de.frosner.broccoli.models._ import de.frosner.broccoli.util.TemporaryDirectoryContext import org.specs2.mutable.Specification import scal...
Explain and rewrite the following Scala code:
package y import org.scalatest.{Matchers, FunSuite} class FirstGlueTest extends FunSuite with Matchers { val numbers = List(1, 2, 4, 6, 8, 10) val booleans = List(true, false, false, true, false) val words1 = List("first", "second", "third") val words2 = List("dog", "cat", "tortoise") test("SumProblem")...
Explain and rewrite the following Scala code:
import korolev._ import korolev.akka._ import scala.concurrent.ExecutionContext.Implicits.global import korolev.server._ import korolev.state.javaSerialization._ import scala.concurrent.Future object RoutingExample extends SimpleAkkaHttpKorolevApp { import State.globalContext._ import levsha.dsl._ import html....
Explain and rewrite the following Scala code:
/* * Copyright 2019 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
/* * Copyright 2014 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in...
Explain and rewrite the following Scala code:
package japgolly.scalajs.react.internal import scala.reflect.macros.blackbox.Context import japgolly.scalajs.react.Children final class ComponentBuilderMacros(val c: Context) extends MacroUtils { import c.universe._ private def createBackend[B: c.WeakTypeTag] = { val B = weakTypeOf[B] val backend = repla...
Explain and rewrite the following Scala code:
/* * Copyright 2007-2010 WorldWide Conferencing, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
Explain and rewrite the following Scala code:
/*************************************************** MySketch */ //package declaration package org.loom.mysketch //import java library classes import java.awt.{Color, Graphics2D, BasicStroke, Image} import java.awt.image.BufferedImage import java.awt.geom._ import java.awt.Polygon import java.io.File imp...
Explain and rewrite the following Scala code:
package fr.hurrycane.tools import akka.actor.ActorRef import com.newmotion.akka.rabbitmq._ import fr.hurrycane.entity.LuisIntent object RabbitFactory { val exchange = sys.env("RABBIT_EXCHANGE") val messageQueue = sys.env("RABBIT_QUEUE_MESSAGE") val messageBinding = sys.env("RABBIT_BINDING_MESSAGE") def getF...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package com.twitter.finagle.postgresql.types import java.nio.charset.{Charset, CharsetDecoder, CodingErrorAction} import com.twitter.finagle.postgresql.PgSqlClientError import com.twitter.finagle.postgresql.PgSqlUnsupportedError import com.twitter.finagle.postgresql.Types.Inet import com.twitter.finagle.postgresql.Typ...
Explain and rewrite the following Scala code:
//package io.youi.example.ui // //import io.youi._ //import io.youi.component.Container //import io.youi.example.screen.UIExampleScreen //import io.youi.layout.VerticalLayout //import io.youi.net._ //import io.youi.paint.Paint //import io.youi.style.{HTMLBorder, HTMLBorderStyle, Overflow} // //import scala.concurrent.F...
Explain and rewrite the following Scala code:
package connectors import model.Device._ import model.{RawDeviceCollection, RawDevice} import play.api.libs.json.Json import play.api.libs.ws.WSResponse import play.api.http.Status._ import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global object WSMock extends org.specs2.mock.Mockito ...
Explain and rewrite the following Scala code:
package pt.cnbc.wikimodels.mathml.elements /** * TODO: Please document. * @author Alexandre Martins * Date: 11/Out/2010 * Time: 1:32:20 */ case class Sep() extends Token
Explain and rewrite the following Scala code:
package models import play.api.libs.json._ import java.util.UUID import play.api.libs.iteratee.Enumerator import org.joda.time.format.ISODateTimeFormat import org.joda.time.DateTime import play.api.data.validation.ValidationError case class Tick() case class TickStart() case class TickStop() object CurrentTime { v...
Explain and rewrite the following Scala code:
object Outer { object Inner { class Bar(x: Int) object Bar } export Inner.Bar._ val _ = apply(2) // error (constructor proxies are not exported) } object Outer2 { object Inner { class Bar(x: Int) object Bar } export Inner.Bar.apply // error: no eligible member val _ = apply(2) ...
Explain and rewrite the following Scala code:
package flaky case class TimeReport(times: Int, duration: Long) { def estimate(timesLeft: Int): String = { val seconds = ((duration / times) * timesLeft)/1000 TimeReport.formatSeconds(seconds) } def estimateCountIn(timeLeft: Long): String = { val r = timeLeft / (duration / times) s"$r times" }...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2018 by The Monix Project Developers. * See the project homepage at: https://monix.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2015, * Ilya Sergey, Christopher Earl, Matthew Might and David Van Horn * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain t...
Explain and rewrite the following Scala code:
package org.http4s package server package middleware import scalaz.stream.Process._ import scalaz.stream.Cause.End import scala.annotation.tailrec import org.http4s.headers.`Content-Length` import scodec.bits.ByteVector import scalaz.Kleisli._ object ChunkAggregator { @tailrec private[ChunkAggregator] def reduce...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
// Copyright (C) 2011 - Will Glozer. All rights reserved. package com.lambdaworks.jacks import com.fasterxml.jackson.core._ import com.fasterxml.jackson.core.JsonToken._ import com.fasterxml.jackson.databind._ import com.fasterxml.jackson.databind.ser.std.StdSerializer import java.lang.reflect.Constructor class Tu...
Explain and rewrite the following Scala code:
package compile import java.io.File import scala.collection.mutable.ArrayBuffer import scala.sys.process._ import json_parser.Error trait Parser { protected val digitsMatch = "([0-9])+".r protected val reasonMatch = ":(.*?)".r protected def removeOldFiles(path: File, fileType: String) = { val compileFile...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
case class User(name: String, email: String, age: Int) object MyUserType extends com.google.gimd.UserType[User] { //define binding between Messages that Gimd stores and some custom class import com.google.gimd._ import com.google.gimd.UserType._ val name = FieldSpecOne("name", StringField, _.name) val email ...
Explain and rewrite the following Scala code:
import sbt.Keys._ import sbt._ object BuildSettings { val Name = "dhira" val Version = "0.0.1" // You can use either version of Scala. We default to 2.11.7: val ScalaVersion = "2.11.7" val ScalaVersions = Seq("2.11.7", "2.10.5") lazy val buildSettings = Defaults.coreDefaultSettings ++ Seq ( name ...
Explain and rewrite the following Scala code:
package scala.meta.tests.semanticdb import java.nio.file.Files import org.scalatest.FunSuite import org.scalatest.tagobjects.Slow import scala.meta.cli.Metac import scala.meta.internal.semanticdb.scalac.SemanticdbPaths import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath import scala.meta.io....
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package com.twitter.finagle.http.filter import com.twitter.conversions.DurationOps._ import com.twitter.finagle.http.codec.HttpDtab import com.twitter.finagle.http.{Request, Response, Status} import com.twitter.finagle.{Dtab, Service} import com.twitter.util.{Await, Future} import org.scalatestplus.junit.AssertionsFor...
Explain and rewrite the following Scala code:
package org.tmoerman.plongeur.tda import java.lang.Math.{min, floor} import org.apache.spark.rdd.RDD import org.tmoerman.plongeur.tda.Filters._ import org.tmoerman.plongeur.tda.Model._ import org.tmoerman.plongeur.util.IterableFunctions._ import org.tmoerman.plongeur.util.RDDFunctions._ /** * @author Thomas Moerma...
Explain and rewrite the following Scala code:
package at.magiun.core.model.data import enumeratum._ import scala.collection.immutable sealed abstract class Distribution(val name: String, val ontClassName: String) extends EnumEntry object Distribution extends Enum[Distribution] with CirceEnum[Distribution] { case object Normal extends Distribution("Normal Di...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.conversion.copy.plainText import java.awt.datatransfer.DataFlavor.stringFlavor import com.intellij.ide.{IdeView, PasteProvider} import com.intellij.openapi.actionSystem.LangDataKeys.{IDE_VIEW, MODULE} import com.intellij.openapi.actionSystem.{CommonDataKeys, DataContext} import com...
Explain and rewrite the following Scala code:
package org.marxc.ast import org.objectweb.asm.MethodVisitor import org.marxc.{SymbolTable} import org.objectweb.asm.Opcodes._ import org.parboiled.errors.ParsingException case class DeclareIntNode(variable: String, value: OperandNode) extends StatementNode { def generate(mv: MethodVisitor, symbolTable: SymbolTab...
Explain and rewrite the following Scala code:
package ozmi.lambda_core.lib trait TypeInstance extends EvalRules { }
Explain and rewrite the following Scala code:
package com.github.utaal.m68k.ast import com.github.utaal.m68k.Size sealed trait Operand sealed trait Register { def number: Int } object Register { case class Data(override val number: Int) extends Register case class Address(override val number: Int) extends Register } sealed trait Literal object Literal {...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2016 dawid.melewski * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publ...
Explain and rewrite the following Scala code:
package rww.rdf import org.w3.banana.RDF /** trait for things that have names */ case class Named[Rdf <: RDF, T](name: Rdf#URI, obj: T) { def map[O](f: T => O): Named[Rdf, O] = Named(name, f(obj)) }
Explain and rewrite the following Scala code:
package com.containant.heuristics import scala.reflect.ClassTag import scala.collection.mutable import com.containant.LBNF trait RandomHeuristic extends Heuristic { val _iterations: Int = 100 val _recursionDepth: Int = 10 val RNG: java.util.Random = new java.util.Random(0xDEADBEEF) def apply(tgrammar: LBN...
Explain and rewrite the following Scala code:
package com.geeksville.dapi.model import com.github.aselab.activerecord.Datestamps import com.github.aselab.activerecord.annotations._ import org.squeryl.annotations.Transient import org.mindrot.jbcrypt.BCrypt import java.util.UUID import com.github.aselab.activerecord.dsl._ import grizzled.slf4j.Logging import java.i...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Twitter inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable l...
Explain and rewrite the following Scala code:
/* * Copyright 2011 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed t...
Explain and rewrite the following Scala code:
/** * This file contains all the messages you will need to implement * your actor system. You are welcome to introduce new messages * as you see fit, however, these are the ones we used in our * implementation. */ package cs220.actors /** * `NeedLink` is sent from the FetchActor to the LinkQueueActor * to ask f...
Explain and rewrite the following Scala code:
package org.dsa.iot.ignition.spark import org.apache.spark.sql.DataFrame import org.dsa.iot.rx.AbstractRxBlock import org.dsa.iot.scala.Having import com.ignition.frame.SparkRuntime import rx.lang.scala.Observable /** * Reads rows from an Apache Cassandra table. */ class CassandraInput(implicit rt: SparkRuntime) ...
Explain and rewrite the following Scala code:
package sc.ala.rubyist import java.net.InetAddress case class Host(ia:InetAddress) { def name = ia.getHostName def address = ia.getHostAddress def identity: String = { if (name.nonEmpty) name else if (address.nonEmpty) address else throw new RuntimeException("Hostname not found...
Explain and rewrite the following Scala code:
package org.littlewings.tweetbot.application.lilymyu.lyrics.repository import javax.enterprise.context.ApplicationScoped import javax.inject.Inject import org.infinispan.Cache import org.littlewings.tweetbot.application.lilymyu.lyrics.qualifier.LilymyuLyricsTweetBot import org.littlewings.tweetbot.standard.lyrics.Lyr...
Explain and rewrite the following Scala code:
package stgy.scalajs import org.scalajs.dom.html.Image import stgy.scalajs.WebApp.Context import sun.net.www.content.image.png object Drawer { def draw(context : Context,frame : StgyFrame)= { context.setTransform(1, 0, 0, 1, 0, 0) val w = context.canvas.width val h = context.canvas.height val ca...
Explain and rewrite the following Scala code:
package scala.meta.tests package api import org.scalatest._ import org.scalameta.tests._ import org.scalameta.explore import scala.compat.Platform.EOL class SurfaceSuite extends scala.meta.tests.ast.AstSuite { import AstReflection._ val reflectedTrees = { val root = symbolOf[scala.meta.Tree].asRoot val al...
Explain and rewrite the following Scala code:
package cn.gridx.scala.lang.generics.TypeTags /** * Created by tao on 11/25/15. */ object InstantiateOneType { def main(args: Array[String]): Unit = { val mirror: scala.reflect.runtime.universe.Mirror = scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader) val c...
Explain and rewrite the following Scala code:
package scuff import org.junit._, Assert._ object TestFakeTypes { sealed abstract class LongWrapper extends FakeType[Long] { private[TestFakeTypes] def unwrap(id: Type): Long } val FooID: LongWrapper = new LongWrapper { type Type = Long def apply(long: Long): Type = long def unwrap(id: Type): Lo...
Explain and rewrite the following Scala code:
package pl.writeonly.son2.path.providers import pl.writeonly.son2.apis.converters.Converter import pl.writeonly.son2.funs.liners.{Liner, LinerOpt} import pl.writeonly.son2.funs.streamers.{Streamer, StreamerPipeForeach} import pl.writeonly.son2.path.chain.ChainNotationPairPath import pl.writeonly.son2.path.core.{Config...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package io.github.yzernik.bitcoinscodec.messages import io.github.yzernik.bitcoinscodec.structures.{Hash, Message, MessageCompanion, VarList} import scodec.Codec import scodec.codecs._ case class GetHeaders( version: Long, block_locator_hashes: List[Hash], hash_stop: Hash = Hash.NULL) extends Message { type E...
Explain and rewrite the following Scala code:
package edu.gemini.dataman.app import scalaz.{-\\/, \\/-} object PidFunctorSpec extends TestSupport { "PidFunctor" should { "find all pids" ! forAllPrograms { (odb, progs) => val expected = progs.map(_.getProgramID).toSet PidFunctor.exec(odb, User) match { case \\/-(actual) => expected == ac...
Explain and rewrite the following Scala code:
/* * Scala (https://www.scala-lang.org) * * Copyright EPFL and Lightbend, Inc. * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). * * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ package scala package reflect ...
Explain and rewrite the following Scala code:
import java.io.{StreamTokenizer, BufferedReader, InputStreamReader, OutputStreamWriter, PrintWriter} object Solution { val writer: PrintWriter = new PrintWriter(new OutputStreamWriter(System.out)) val reader: BufferedReader = new BufferedReader(new InputStreamReader(System.in)) val tokenizer: StreamTokenizer = n...
Explain and rewrite the following Scala code:
package com.github.j5ik2o.spetstore import akka.http.scaladsl.server.Directives._ import com.github.j5ik2o.spetstore.adaptor.http.{ CreateCustomerJson, CustomerSupport } import com.github.j5ik2o.spetstore.json.{ CreateCustomerJsonProtocol, CustomerCreatedJsonProtocol } trait CustomerRoute extends CustomerSupport { ...
Explain and rewrite the following Scala code:
package org.jscala import language.dynamics import scala.util.matching.Regex import java.lang class JString(s: String) { val length = 0 def charAt(i: Int) = "" def charCodeAt(i: Int) = 0 def indexOf(item: String): Int = 0 def lastIndexOf(item: String): Int = 0 def `match`(regexp: Regex): JArray[JString] =...
Explain and rewrite the following Scala code:
/* * SPDX-License-Identifier: Apache-2.0 * * Copyright 2015-2021 Andre White. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * ...
Explain and rewrite the following Scala code:
package com.twitter.finatra.tests.conversions import com.twitter.finatra.conversions.seq._ import com.twitter.inject.Test class SeqConversionsTest extends Test { "RichSeq" should { "#extractMap" in { val map = Seq("a", "and") createMap(_.size, _.toUpperCase) map should equal(Map(1 -> "A", 3 -> "AN...
Explain and rewrite the following Scala code:
package redmine4s.api.model import redmine4s.RedmineException sealed class ModelException private[redmine4s](message: String = null, cause: Throwable = null) extends RedmineException(message, cause) final class FormatConversionException private[redmine4s](message: String = null, cause: Throwable = null) extends Mode...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
Explain and rewrite the following Scala code:
package com.viajobien.busy.dsl.condition import org.scalatest.{ Matchers, WordSpecLike } import play.api.libs.json.Json import play.api.mvc.{ AnyContentAsEmpty, AnyContentAsJson, Headers } import play.api.test.FakeRequest /** * @author david on 24/11/14. */ class ConditionSpec extends WordSpecLike with Matchers { ...
Explain and rewrite the following Scala code:
package org.moe.interpreter import org.scalatest.FunSuite import org.moe.runtime._ import org.moe.ast._ class ComparisonNodeTestSuite extends FunSuite with InterpreterTestUtils { test("... basic test with <") { val ast = wrapSimpleAST( List( BinaryOpNode( IntLiteralNode(4), "...
Explain and rewrite the following Scala code:
package yandex.direct import org.specs2.mutable._ import org.specs2.specification._ import play.api.libs.json._ import org.joda.time.DateTime class DirectSpec extends Specification with AllExpectations { //initialize Direct parameters Global._APPLICATION_ID = "e3a82ab5b4054deda4bb917d2a537224" val direct = D...
Explain and rewrite the following Scala code:
package com.github.mdr.mash.ns.os import java.nio.file.{ Files, Path, Paths } import com.github.mdr.mash.completions.CompletionSpec import com.github.mdr.mash.functions.{ BoundParams, MashFunction, Parameter, ParameterModel } import com.github.mdr.mash.inference.TypedArguments import com.github.mdr.mash.os.CurrentDir...
Explain and rewrite the following Scala code:
package com.itszuvalex.itszulib.implicits import com.itszuvalex.itszulib.api.core.NBTSerializable import net.minecraft.nbt.{NBTBase, NBTTagCompound, NBTTagList} import scala.collection.JavaConversions._ import scala.collection.TraversableOnce /** * Created by Christopher on 8/17/2015. */ object NBTHelpers { obj...
Explain and rewrite the following Scala code:
package net.itsky.sortsearch.fsort import org.scalatest._ class HeapSortTest extends FlatSpec with Matchers { val cmp = Ordering.Int "An empty Array" should "be sorted without any changes" in { val arr : Array[Int] = Array() HeapSort.hsort(arr, cmp) arr.length should be (0) } "An empty segment...
Explain and rewrite the following Scala code:
package scalaoauth2.provider import org.scalatest.FlatSpec import org.scalatest.Matchers._ class RefreshTokenSpec extends FlatSpec { it should "handle request" in { val refreshToken = new RefreshToken(new MockClientCredentialFetcher()) val request = AuthorizationRequest(Map(), Map("refresh_token" -> Seq("r...
Explain and rewrite the following Scala code:
package org.channing.free import cats.free.Free import cats.free.Free._ import cats.~> object Layer1 { type L1Op[A] = Free[L1OpA, A] sealed trait L1OpA[A] case class Op1(arg: String) extends L1OpA[String] def op1(arg: String): L1Op[String] = liftF[L1OpA, String](Op1(arg)) import Store._ def store...
Explain and rewrite the following Scala code:
package cwl import io.circe._ import io.circe.parser._ import io.circe.shapes._ import io.circe.generic.auto._ import eu.timepit.refined.string._ import io.circe.refined._ import io.circe.literal._ object CwlCodecs { import Implicits._ //According to automatic derivation, these instances should not be required. ...
Explain and rewrite the following Scala code:
import java.time._ import sangria.macros._ import types._ object HeroAndFriends { object HeroAndFriends extends GraphQLQuery { val document: sangria.ast.Document = graphql"""query HeroAndFriends { hero { name friends { name friends { name friends { name fr...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
// NOTE: copy/pasted from https://github.com/lampepfl/dotty/tree/1962ada58fcd2333a2e40179ab0ac6efb6167ed2 package scala.meta package internal.hosts.scalac package tasty import reflect.ClassTag object Util { /** The index `i` in `candidates.indices` such that `candidates(i) <= x` and * `candidates(i)` is close...
Explain and rewrite the following Scala code:
import scala.concurrent.duration.DurationDouble 1.2.seconds // scala.concurrent.duration.FiniteDuration = 1200 milliseconds (1.0/60).seconds // scala.concurrent.duration.FiniteDuration = 16666667 nanoseconds
Explain and rewrite the following Scala code:
/* * Copyright 2016 Dennis Vriend * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed t...
Explain and rewrite the following Scala code:
val textFile = sc.textFile("README.md", 4) val words = textFile.flatMap(line => line.split("[\\\\s]+")) val realWords = words.filter(_.nonEmpty) val wordTuple = realWords.map(word => (word, 1)) val groupBy = wordTuple.groupByKey(2) val wordCount = groupBy.mapValues(value => value.reduce(_ + _)) wordCount.collect().sort...
Explain and rewrite the following Scala code:
case class Point(x: Float, y: Float)
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
// Copyright: 2010 - 2017 https://github.com/ensime/ensime-server/graphs/contributors // License: http://www.gnu.org/licenses/lgpl-3.0.en.html package org.ensime.sexp import java.io.File import java.net.URI import java.util.UUID class StandardFormatsSpec extends FormatSpec { "StandardFormats" should "support Opti...
Explain and rewrite the following Scala code:
/* * Copyright 2014 DataGenerator Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
Explain and rewrite the following Scala code:
package com.github.ldaniels528.commons.helpers /** * String Helper Utility Class * @author Lawrence Daniels <lawrence.daniels@gmail.com> */ object StringHelper { implicit class ByteArrayExtensions(val bytes: Array[Byte]) extends AnyVal { def isPrintable: Boolean = bytes forall (b => b >= 32 && b <= 127) ...
Explain and rewrite the following Scala code:
package code package config import net.liftweb._ import common.{Loggable, MDC} import http.{Factory, LiftRules, RedirectResponse, Req, S, XhtmlResponse} import util.Props object ErrorHandler extends Factory with Loggable { // config val errorUrl = new FactoryMaker[String]("/error") {} // where to send the user wh...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* __ *\\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\\___/_/...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2016 Christopher Batey and Dogan Narinc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by appli...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2016 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and is ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Copyright 2015-2016 IBM Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
Explain and rewrite the following Scala code:
package gapt.proofs.lk.transformations import gapt.expr.formula.All import gapt.expr.formula.And import gapt.expr.formula.Formula import gapt.expr.formula.hol.containsStrongQuantifier import gapt.expr.formula.hol.isPrenex import gapt.expr.formula.hol.universalClosure import gapt.expr.util.freeVariables import gapt.log...
Explain and rewrite the following Scala code:
/** * © 2019 Refinitiv. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable l...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package net.fwbrasil.smirror class VisibilitySpec extends SMirrorSpec { def testPrivatePackage(subject: Visibility[_, _]) { subject.isPrivateWithin should equal(true) subject.isPrivate should equal(false) subject.isProtected should equal(false) subject.isVisibleFrom(sClassOf[Any]) ...
Explain and rewrite the following Scala code:
package org.kuleuven.mai.vision.image import org.kuleuven.mai.vision.utils.median import breeze.linalg.{sum, max, min, DenseVector} import scala.collection.mutable.{MutableList => ML} /** * @author koldh */ class RadioGraph (imag: List[ML[Int]], r: Int) { def apply(x: Int)(y: Int): Int = imag(x)(y) def getCo...