instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package beam.router.r5
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file._
import java.util
import beam.sim.BeamServices
import beam.sim.config.BeamConfig
import com.conveyal.gtfs.GTFSFeed
import com.conveyal.gtfs.model.Trip
import com.conveyal.r5.analyst.scenario.{AddTrips, AdjustFrequency, Sce... |
Explain and rewrite the following Scala code: | package at.logic.gapt.examples
import at.logic.gapt.expr._
import at.logic.gapt.proofs.Sequent
import at.logic.gapt.proofs.lk._
object CERESExpansionExampleProof {
val c = FOLConst( "c" )
val x = FOLVar( "x" )
val y = FOLVar( "y" )
val z = FOLVar( "z" )
def f( x: FOLTerm ) = FOLFunction( "f", List( x ) )
... |
Explain and rewrite the following Scala code: | import scala.reflect.runtime.universe._
import scala.tools.reflect.Eval
object Test extends App {
{
val x = 42
def foo() = reify{ val y = x; reify{ val z = y * x; reify(z * x) } };
{
val x = 2
val code1 = foo()
val code2 = code1.eval
val code3 = code2.eval
println(code3.eval... |
Explain and rewrite the following Scala code: | package scalaz.stream
import scalaz.{Monad, Monoid, Equal}
trait These[+A,+B] {
import These._
def flip: These[B,A] = this match {
case This(x) => That(x)
case That(x) => This(x)
case Both_(x,y) => Both_(y,x)
}
def mapThis[A2](f: A => A2): These[A2,B] = this match {
case This(a) => This(f(a)... |
Explain and rewrite the following Scala code: | /*
* Copyright 2021 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: | package app.state
import commands._
trait AppState {
def commands:Set[Command]
override def toString: String = "Not implemented"
}
|
Explain and rewrite the following Scala code: | package cobalt.parser
import fastparse.noApi._
import WsApi._
import cobalt.ast.AST._
import cobalt.ast.AST
import cobalt.parser.ExpressionParser.newClassInstanceParser
object ExpressionParser {
def accessModifier: P[Modifier] = P(LexicalParser.kw("protected")).map(_ => Protected()) | P(LexicalParser.kw("private")... |
Explain and rewrite the following Scala code: | package cdgp
import swim.tree.Op
import sygus._
import sygus16.SyGuS16
import scala.collection.mutable
class Query(val code: String, val mainCmd: String = "(check-sat)\\n",
val satCmds: String = "", val unsatCmds: String = "") {
/**
* @return Full script with both a sat and unsat branches placed ... |
Explain and rewrite the following Scala code: |
object Main{
def main(args: Array[String]){
var myGrid = new Grid(200,200)
DisplayIt.init(myGrid)
}
}
|
Explain and rewrite the following Scala code: | package ecommerce.shipping
import pl.newicom.dddd.actor.{Config, ConfigClass}
import pl.newicom.dddd.aggregate._
import pl.newicom.dddd.office.LocalOfficeId
import pl.newicom.dddd.office.LocalOfficeId.fromRemoteId
object Shipment extends AggregateRootSupport {
sealed trait Shipping extends Behavior[Event, Shipping... |
Explain and rewrite the following Scala code: | package chandu0101.scalajs.react.components.demo.components.materialui
import chandu0101.scalajs.react.components.demo.components.CodeExample
import chandu0101.scalajs.react.components.demo.components.materialui.svgicons._
import chandu0101.scalajs.react.components.materialui.{MuiListDivider, MuiListItem, MuiList, Mui... |
Explain and rewrite the following Scala code: | package org.broadinstitute.dsde.firecloud.webservice
import akka.http.scaladsl.client.RequestBuilding
import akka.http.scaladsl.server.{Directives, Route}
import org.broadinstitute.dsde.firecloud.model.MethodRepository.FireCloudPermission
import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol._
import org.br... |
Explain and rewrite the following Scala code: | // This file is a collection of simple snippets that could be run individually.
// See Scala doc page for more: https://github.com/panchul/workspace/blob/master/doc/Scala.md
// run it as
// $ scala timing_execution.sc
println("Hello there!")
def time[R](block: => R): R = {
val time_start = System.nanoTime()
val ... |
Explain and rewrite the following Scala code: | package com.karasiq.shadowcloud.webapp.components.file
import com.karasiq.bootstrap.Bootstrap.default._
import com.karasiq.common.memory.SizeUnit
import com.karasiq.highlightjs.HighlightJS
import com.karasiq.markedjs.{Marked, MarkedOptions, MarkedRenderer}
import com.karasiq.shadowcloud.model.File
import com.karasiq.s... |
Explain and rewrite the following Scala code: | package io.sandbox.web.domain
case class Person(id: Int, name: String, age: Option[Int]) {
}
|
Explain and rewrite the following Scala code: | import com.typesafe.config._
object Lib {
lazy val config = ConfigFactory.load()
def int: Int = config.getInt("foo.int")
}
|
Explain and rewrite the following Scala code: | object Test {
import collection.{ immutable, mutable, generic }
def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF
val cbf1 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, collection.IndexedSeq[Int]]]
val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, collection.Indexed... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package util.macroDebug
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
/**
* ... |
Explain and rewrite the following Scala code: | package org.bitcoins.spvnode.serializers.messages.control
import org.bitcoins.core.number.UInt64
import org.bitcoins.core.serializers.RawBitcoinSerializer
import org.bitcoins.core.util.BitcoinSUtil
import org.bitcoins.spvnode.messages.control.ServiceIdentifier
/**
* Created by chris on 6/2/16.
* Responsible for s... |
Explain and rewrite the following Scala code: | package metascala.test
object TuplesTest {
import metascala.Tuples._
val t1 = (10, "Hello", true)
val t2 = ((10, 20), 10.1)
val t3 : (Int, String, Boolean, (Int, Int), Double) = append(t1, t2)
val t4 : (Double, (Int, Int), Boolean, String, Int) = reverse(t3)
val t5 : (Int, String, Boolean) = t1 replace ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012 Eike Kettner
*
* 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... |
Explain and rewrite the following Scala code: | package huhong.scala.common.dao
import java.io.Serializable
import huhong.scala.common.hibernate.query.Query
import huhong.scala.navigator.Navigator
import huhong.scala.common.hibernate._
import org.slf4j.LoggerFactory
import scala.collection.JavaConverters._
/**
* Created by huhong on 15/1/15.
*/
trait QueryDao... |
Explain and rewrite the following Scala code: | package at.logic.gapt.proofs.lk
object quantRulesNumber {
def apply( p: LKProof ): Int =
p.treeLike.postOrder count {
case StrongQuantifierRule( _, _, _, _, _ ) => true
case WeakQuantifierRule( _, _, _, _, _, _ ) => true
case _ => false
}
}
object weak... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012-2016 Netflix, 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 agr... |
Explain and rewrite the following Scala code: | package sigmastate.utxo.examples
import org.ergoplatform._
import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert, Lookup}
import scorex.crypto.authds.{ADKey, ADValue}
import scorex.crypto.hash.{Blake2b256, Digest32}
import sigmastate.SCollection.SByteArray
import sigmastate.Values._
import sigmastate._
imp... |
Explain and rewrite the following Scala code: | package concrete
package constraint
package semantic
import bitvectors.BitVector
object Task {
def apply(ps: ProblemState, s: Variable, d: Variable, h: Variable): Task = {
val sDom = ps.dom(s)
val dDom = ps.dom(d)
Task(d, h, sDom.head, dDom.head, sDom.last + dDom.last, ps.dom(h).head)
}
}
case class ... |
Explain and rewrite the following Scala code: | package de.tudarmstadt.lt.flinkdt
object DbIO extends App {
// INPUT
//// Read data from a relational database using the JDBC input format
//DataSet<Tuple2<String, Integer> dbData =
// env.createInput(
// // create and configure input format
// JDBCInputFormat.buildJDBCInputFormat()
// ... |
Explain and rewrite the following Scala code: | package de.zalando.model
import de.zalando.apifirst.Application._
import de.zalando.apifirst.Domain._
import de.zalando.apifirst.ParameterPlace
import de.zalando.apifirst.naming._
import de.zalando.apifirst.Hypermedia._
import de.zalando.apifirst.Http._
import de.zalando.apifirst.Security
import java.net.URL
import Sec... |
Explain and rewrite the following Scala code: | /*
# Copyright 2016 Georges Lipka
#
# 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 wri... |
Explain and rewrite the following Scala code: | package com.sandinh.soap
import java.time.{LocalDate, LocalDateTime}
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME
class SOAPDate(date: LocalDateTime, dateFormatter: DateTimeFormatter) {
override def toString: String = dateFormatter.format(date)
def toDate... |
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 es.upm.oeg.epnoi.matching.metrics.similarity
import es.upm.oeg.epnoi.matching.metrics.distance.JensenShannonDivergence
/**
* Created by cbadenes on 22/04/15.
*
* Measure of similarity based on the Jensen-Shannon Divergence between two density functions
*/
object JensenShannonSimilarity {
def apply(p: A... |
Explain and rewrite the following Scala code: | package spark.storage
import akka.actor.Actor
import spark.{Logging, SparkException, Utils}
/**
* An actor to take commands from the master to execute options. For example,
* this is used to remove blocks from the slave's BlockManager.
*/
class BlockManagerSlaveActor(blockManager: BlockManager) extends Actor {
... |
Explain and rewrite the following Scala code: | package codechicken.microblock
import net.minecraft.block.Block
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
import net.minecraft.util.IIcon
import cpw.mods.fml.relauncher.SideOnly
import cpw.mods.fml.relauncher.Side
import net.minecraft.item.ItemStack
import codechicken.lib.vec.{Cuboid6, Vector3... |
Explain and rewrite the following Scala code: | package com.datastax.spark.connector.util
import com.datastax.driver.core.{TypeCodec, CodecRegistry, DataType}
object CodecRegistryUtil {
def codecFor(cqlType: DataType, value: AnyRef) : TypeCodec[AnyRef] = {
if(value==null) CodecRegistry.DEFAULT_INSTANCE.codecFor(cqlType)
else CodecRegistry.DEFAULT_INSTANC... |
Explain and rewrite the following Scala code: | object Test extends dotty.runtime.LegacyApp {
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox
val tree = Select(Ident(TermName("Macros")), TermName("foo"))
try cm.mkToolBox().eval(tree)
catch { case ex: Throwable => println(ex.... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017-2020 47 Degrees Open Source <https://www.47deg.com>
*
* 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 ... |
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
import java.net.{SocketAddress, InetSocketAddress}
/**
* A SocketAddress with a weight. `WeightedSocketAddress` can be nested.
*/
case class WeightedSocketAddress(addr: SocketAddress, weight: Double) extends SocketAddress
object WeightedSocketAddress {
/**
* Extract `SocketAddress`... |
Explain and rewrite the following Scala code: | package ch.epfl.lamp.odds
package internal
import functors.ProbMonad
/** Base trait for ODDS Language interface. */
trait OddsBase {
/** Abstract random variable type. */
type Rand[+A] <: RandBase[A]
/** Abstract distribution type. */
type Dist[+A]
/** Base trait for random variables. */
trait RandBas... |
Explain and rewrite the following Scala code: | package com.technophobia.substeps.domain
import scala.util.matching.Regex
import com.technophobia.substeps.domain.repositories.SubstepRepository
/**
* @author rbarefield
*/
abstract class Substep(val regex: Regex) {
assert(regex != null)
def createInvocation(substepRepository: SubstepRepository, invocation: ... |
Explain and rewrite the following Scala code: | package com.arcusys.learn.liferay.update.version300.migrations
import com.arcusys.learn.liferay.update.SlickDBContext
import com.arcusys.learn.liferay.update.migration.GoalType
import com.arcusys.learn.liferay.update.version300.{certificate => oldScheme}
import com.arcusys.learn.liferay.update.version300.{certificate3... |
Explain and rewrite the following Scala code: | package com.github.rosmith.nlp.service.util
import java.util.Properties
import java.io.InputStreamReader
import java.io.FileInputStream
import java.util.function.Consumer
import com.github.rosmith.nlp.query.util.Helper
import com.github.rosmith.nlp.query.solution.QuerySolutionImpl
import com.github.rosmith.nlp.query.s... |
Explain and rewrite the following Scala code: | // Copyright (C) 2010 The Android Open Source Project
//
// 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 ... |
Explain and rewrite the following Scala code: | package cook.actor.impl
import cook.actor.ConfigRefManager
import cook.actor.impl.util.BatchResponser
import cook.actor.impl.util.TaskBuilder
import cook.app.Global
import cook.config.ConfigRef
import cook.console.ops._
import cook.error._
import cook.ref.FileRef
import cook.util.DagSolver
import scala.concurrent.{ F... |
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 2022 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: | package microtools
import microtools.logging.LoggingContext
import microtools.models.{Problem, Problems}
import org.scalamock.scalatest.MockFactory
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{MustMatchers, WordSpec}
import play.api.libs.json.Json
import play.api.mvc.{Result, Results}
import play... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
package play.core
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import play.api._
import play.api.inject.DefaultApplicationLifecycle
import play.api.routing.Router
package object test {
/**
* Run the given block of ... |
Explain and rewrite the following Scala code: | class A[T]
object o {
// Testing compiler crash, this test should be modified when named type argument are completely implemented
val x: A[T=Int, T=Int] = ??? // error: ']' expected, but '=' found
}
|
Explain and rewrite the following Scala code: | /*
* __________ ______ __ ________ _ __ ______
* /_ __/ __ \\/ _/ / / / / _/ __ \\/ | / / / ____/
* / / / /_/ // // / / / / // / / / |/ / / / __
* / / / _, _// // /___/ /____/ // /_/ / /| / / /_/ /
* /_/ /_/ |_/___/_____/_____/___/\\____/_/ |_/ \\____/
*
* C... |
Explain and rewrite the following Scala code: | package temportalist.esotericraft.utils.client
import net.minecraftforge.client.model.{ModelLoader, ModelLoaderRegistry}
import temportalist.esotericraft.api.init.IPluginClient
import temportalist.esotericraft.main.common.EsoTeriCraft
import temportalist.esotericraft.utils.client.multi.ModelLoaderMulti
import temporta... |
Explain and rewrite the following Scala code: | package scala.scalanative
import scala.reflect.ClassTag
import native._
import runtime.Intrinsics._
package object runtime {
/** Used as a stub right hand of intrinsified methods. */
def undefined: Nothing = throw new UndefinedBehaviorError
/** Returns info pointer for given type. */
def typeof[T](implicit ... |
Explain and rewrite the following Scala code: | package com.hoszu.spark
import org.apache.spark.{SparkConf, SparkContext}
/**
* Created by hoszu on 12.03.2015.
*/
object TrxAnalyzerOfflineDriver {
def run(args: Array[String]): Unit = {
val atmsFile = args(0)
val trxFile = args(1)
val outDir = args(2)
val fraudulencyLimit = args(3).toDouble
... |
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.felixmilea.vorbit.http
import scala.collection.mutable.ListBuffer
import akka.actor.Actor
import akka.io.{ IO, Tcp }
import akka.util.ByteString
import com.felixmilea.vorbit.http.Util._
import com.felixmilea.vorbit.utils.Loggable
class HttpHandler(responder: RootNode) extends Actor with Loggable {
impor... |
Explain and rewrite the following Scala code: | package com.etsy.scalding.jobs.conjecture
import com.twitter.scalding.{Args, Job, Mode, SequenceFile, Tsv}
import com.etsy.conjecture.scalding.evaluate.BinaryCrossValidator
import com.etsy.conjecture.scalding.train.BinaryModelTrainer
import com.etsy.conjecture.data.{BinaryLabel,BinaryLabeledInstance,StringKeyedVector}... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2015 Red Bull Media House GmbH <http://www.redbullmediahouse.com> - 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/li... |
Explain and rewrite the following Scala code: | ///**
// * Copyright 2016 - Caspida Inc., All rights reserved.
// * This is Caspida proprietary and confidential material and its use
// * is subject to license terms.
// * Created on 7/15/16.
// *
// * @author joez
// */
//
//package com.aktaion.ml.spark.randomforest
//
//import com.aktaion.common.SparkTestTool... |
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... |
Explain and rewrite the following Scala code: | package io.udash.web.guide.demos.frontend
import io.udash.web.SeleniumTest
import org.openqa.selenium.By.{ByClassName, ByCssSelector, ByTagName}
import scala.collection.JavaConverters._
import scala.util.Random
class FrontendFormsTest extends SeleniumTest {
val url = "/frontend/forms"
"FrontendForms view" shoul... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015 Thomson Reuters
*
* 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 ag... |
Explain and rewrite the following Scala code: | package dbtarzan.gui
import dbtarzan.messages._
import dbtarzan.db.DatabaseId
trait TDatabases {
def handleDatabaseIdMessage(msg: TWithDatabaseId) : Unit
def handleQueryIdMessage(msg: TWithQueryId) : Unit
def handleTableIdMessage(msg: TWithTableId) : Unit
def showDatabase(databaseId : DatabaseId) : Boolean
} |
Explain and rewrite the following Scala code: | package com.twitter.inject.thrift.integration.serviceperendpoint
import com.twitter.finagle.http.Request
import com.twitter.finatra.http.Controller
import com.twitter.greeter.thriftscala.Greeter
import com.twitter.greeter.thriftscala.Greeter.{Bye, Hello, Hi}
import com.twitter.test.thriftscala.EchoService
import com.t... |
Explain and rewrite the following Scala code: | package com.eevolution.context.dictionary.infrastructure.repository
import java.util.UUID
import com.eevolution.context.dictionary.domain._
import com.eevolution.context.dictionary.domain.model.Task
import com.eevolution.context.dictionary.infrastructure.db.DbContext._
import com.eevolution.utils.PaginatedSequence
im... |
Explain and rewrite the following Scala code: | package constants
/**
* Created by pnagarjuna on 09/08/15.
*/
object Urls {
val GoogleOauth2 = "https://accounts.google.com/o/oauth2/auth"
val TokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"
object Calendar {
val calendarList = "https://www.googleapis.com/calendar/v3/users/me/calendarList"
... |
Explain and rewrite the following Scala code: | package binconcifar
import chisel3._
import chisel3.util._
import java.io._
// blackbox to implement ROM
class DenseBlackBox(
weights : Seq[Seq[Int]],
tPut : Int,
weightsBW : Int = 2
) extends BlackBox with HasBlackBoxInline {
val uintWeights = {
if ( weightsBW == 2 ) {
weights.map( nums => {
... |
Explain and rewrite the following Scala code: | package io.sqooba.oss.timeseries.archive
import java.io.OutputStream
import io.sqooba.oss.timeseries.immutable.TSEntry
import io.sqooba.oss.timeseries.thrift.{TBlockType, TSampledBlockType, TSuperBlockMetadata}
import io.sqooba.oss.timeseries.utils.{SliceableByteChannel, ThriftMarshaller}
import org.apache.thrift.TEx... |
Explain and rewrite the following Scala code: | /*
* Copyright 2022 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: | package org.kuleuven.mai
import scala.util.Random
/**
* @author mandar2812
*/
package object utils {
def median(list: Seq[Double]): Double = {
val random: (Int) => Int = Random.nextInt
def medianK(list_sample: Seq[Double], k: Int, pivot: Double): Double = {
val split_list = list_sample.partition(_ <... |
Explain and rewrite the following Scala code: | package debop4s.core.io
import debop4s.core.AbstractCoreFunSuite
import org.mockito.Matchers._
import org.mockito.Mockito._
import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Answer
import org.scalatest.mock.MockitoSugar
/**
* BufferTest
* @author Sunghyouk Bae
*/
class BuffFunSuite extends... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015 Ram Sriharsha
*
* 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 i... |
Explain and rewrite the following Scala code: | class Capture
class Test {
def test1 = (i: Int) => ""
def test2 = (i: VC) => i
def test3 = (i: Int) => i // not adapted, specialized
def test4 = {val c = new Capture; (i: Int) => {(c, Test.this.toString); 42} } // not adapted, specialized
def test5 = {val c = new Capture; (i: VC) => (c, Test.this.toString) }... |
Explain and rewrite the following Scala code: | package com.marekkadek.scrawler.crawlers
import com.marekkadek.scrawler.ScrawlerTest
import org.scalatest.Matchers._
import com.marekkadek.scrawler.opencrawling._
import fs2._
trait CompareCrawling extends ScrawlerTest with BrowserAgnostic[Task] {
implicit val s: Strategy = Strategy.fromFixedDaemonPool(maxThreads ... |
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 scala.slick.ast
import scala.math.{min, max}
import scala.collection.mutable.{ArrayBuffer, HashMap}
import java.io.{StringWriter, PrintWriter, OutputStreamWriter}
import scala.slick.SLICKException
import scala.slick.ql.{ConstColumn, ShapedValue}
import scala.slick.util.{RefId, SimpleTypeName}
trait NodeGenera... |
Explain and rewrite the following Scala code: | package actors
import java.sql.Timestamp
import akka.event.{ActorEventBus, LookupClassification}
import objects.{DBMessage, UserRecord}
import org.joda.time.DateTime
import play.api.libs.json.Json.{fromJson, toJson}
import play.api.libs.json.{Format, JsResult, JsValue, Json}
/**
* Created by theer on 23.05.2017.
... |
Explain and rewrite the following Scala code: | package org.positronicnet.sample.contacts
import org.positronicnet.content._
import org.positronicnet.orm._
import org.positronicnet.notifications._
import org.positronicnet.notifications.Actions._
import org.positronicnet.orm.Actions._
import org.positronicnet.util.ReflectiveProperties
import org.positronicnet.util.... |
Explain and rewrite the following Scala code: | /*
* Copyright 2022 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: | package macros
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
object Provider {
def tree(args: Any): Any = macro treeImpl
def treeImpl(c: blackbox.Context)(args: c.Expr[Any]) = sys.error("no macro for you!")
}
|
Explain and rewrite the following Scala code: | package net.machinemuse.api.electricity
import cofh.api.energy.IEnergyContainerItem
import net.machinemuse.powersuits.common.ModCompatability
import net.minecraft.item.ItemStack
object ElectricAdapter {
def wrap(stack: ItemStack): ElectricAdapter = {
if (stack == null) return null
val i = stack.getItem
... |
Explain and rewrite the following Scala code: | /**
* Licensed to Big Data Genomics (BDG) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The BDG licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use ... |
Explain and rewrite the following Scala code: | package org.hammerlab.args
import caseapp.core.ArgParser
import caseapp.core.ArgParser.instance
import cats.syntax.either._
import org.hammerlab.args.Range.toGuavaRange
import org.hammerlab.guava.collect.{ RangeSet, TreeRangeSet }
import shapeless._
trait Integral[T] {
def +(a: T, b: T): T
def one: T
}
import ja... |
Explain and rewrite the following Scala code: | package com.gx.magnet
/**
* Copyright 2017 josephguan
*
* 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 ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 Adam Rosenberger
*
* 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... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014. Mount Sinai School of Medicine
*
* 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 appl... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.health
import java.net.{ InetAddress, ServerSocket }
import akka.actor.Props
import akka.testkit.{ ImplicitSender, TestActorRef }
import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol
import mesosphere.marathon.state.AppDefinition
import mesosphere.marathon.state.PathId._
import... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 Databricks
*
* 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 i... |
Explain and rewrite the following Scala code: | package akkaHttp.routes
import akka.actor.ActorSystem
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.server.Directives._
import akka.stream.{ActorFlowMaterializer, FlowMaterializer}
import scala.concurrent.ExecutionContextExecutor
class PatternMatchingSuccess {
implicit val system: ActorSy... |
Explain and rewrite the following Scala code: | package reactivedropbox.actors
import akka.actor.Actor
import scala.concurrent.duration._
import com.dropbox.core.{DbxAppInfo, DbxWebAuthNoRedirect}
import reactivedropbox.Global
import reactivedropbox.core.AppInfo
/**
*
*/
class Authorization extends Actor {
/**
* Request a new authorization URL and add the ... |
Explain and rewrite the following Scala code: | /**
Copyright 2010-2013 Ontology Engineering Group, Universidad Politécnica de Madrid, Spain
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... |
Explain and rewrite the following Scala code: | package org.melvinwm.calculator.parsing.test
import org.specs2.mutable.Specification
import scalaz.{\/, \/-, -\/}
import org.melvinwm.calculator.ast.AST._
import org.melvinwm.calculator.parsing.ExpressionParsers
object ExpressionParserTest extends Specification {
private[this] def parseOk(input: String) = {
... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2013 Artima, 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 agre... |
Explain and rewrite the following Scala code: | package equellatests.pages
import com.tle.webtests.framework.PageContext
import com.tle.webtests.pageobject.ExpectedConditions2
import equellatests.browserpage.NewTitledPage
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.{By, Keys, WebElement}
case class LoginNoticePage(ctx: PageC... |
Explain and rewrite the following Scala code: | /*
* Licensed to Intel Corporation under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* Intel Corporation licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use t... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015, deepsense.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.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed ... |
Explain and rewrite the following Scala code: | /**
* Definition for singly-linked list.
* class ListNode(_x: Int = 0, _next: ListNode = null) {
* var next: ListNode = _next
* var x: Int = _x
* }
*/
object Solution {
def addTwoNumbers(l1: ListNode, l2: ListNode): ListNode = {
def addTwoNumbersHelper(l1: ListNode, l2: ListNode, carry: Int): List... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2016-2022 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apach... |
Explain and rewrite the following Scala code: | /*
Copyright 2011 the original author or authors.
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.