instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package org.sisioh.aws4s.dynamodb.model
import com.amazonaws.services.dynamodbv2.model.{ AttributeValue, ConsumedCapacity, GetItemResult }
import org.sisioh.aws4s.PimpedType
import scala.collection.JavaConverters._
object GetItemResultFactory {
def create(): GetItemResult = new GetItemResult()
}
class RichGetIt... |
Explain and rewrite the following Scala code: | package example
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl._
import scala.concurrent.Future
import scala.concurrent.duration._
object Batching extends App {
implicit val sys = ActorSystem("akka-stream-patterns")
implicit val mat = ActorMaterializer()
Source(1 to 100)
.g... |
Explain and rewrite the following Scala code: | package jk_5.nailed.map.gameloop.instructions
import jk_5.nailed.map.gameloop.GameThread
import jk_5.nailed.map.gameloop.IInstruction
/**
* No description given
*
* @author jk-5
*/
class InstructionStopWinnerInterrupt extends IInstruction {
def injectArguments(arguments: String){}
def execute(controller: Game... |
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 Heiko Seeberger
*
* 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: | package cs4r.labs.learningscala.ninetynineproblems
/**
* Reverse a list.
*/
object Problem5 {
def reverse[T](list: List[T]): List[T] = list match {
case Nil => Nil
case head :: tail => reverse(tail) :+ head
}
def reverseTailRecursive[T](list: List[T]): List[T] = {
def reverse2(result: List[T],... |
Explain and rewrite the following Scala code: | /*
* Scala.js (https://www.scala-js.org/)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.nscplugin
import java.net... |
Explain and rewrite the following Scala code: | //package com.sksamuel.avro4s.record.decoder
//
//import com.sksamuel.avro4s.{AvroEnumDefault, AvroSchema, Decoder}
//import com.sksamuel.avro4s.schema.{Colours, CupcatAnnotatedEnum, CupcatEnum, CuppersAnnotatedEnum, SnoutleyEnum, Wine}
//import org.apache.avro.generic.GenericData
//import org.apache.avro.generic.Gener... |
Explain and rewrite the following Scala code: | /*
* Scala.js (https://www.scala-js.org/)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.testing.adapter
object Te... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.util
import java.awt.Event
import java.awt.event.MouseEvent
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicLong
import com.intellij.concurrency.JobScheduler
import com.intellij.diagnostic.PerformanceWatcher
import com.intellij.ide.{ApplicationInitiali... |
Explain and rewrite the following Scala code: | package services
import javax.inject.{Inject, Singleton}
import conf.AppConf
import com.google.api.client.googleapis.auth.oauth2.{GoogleIdToken, GoogleIdTokenVerifier}
import com.google.api.client.json.jackson2.JacksonFactory
import play.api.Logger
import scala.util.Try
/**
* https://developers.google.com/identity... |
Explain and rewrite the following Scala code: | package unfiltered.netty
import org.specs2.mutable.Specification
import io.netty.buffer.Unpooled
import io.netty.handler.codec.http.{ DefaultFullHttpRequest, DefaultFullHttpResponse, HttpResponseStatus, HttpMethod, HttpVersion }
// todo: move to its own file
class RequestSpec extends Specification {
val payload = ... |
Explain and rewrite the following Scala code: | package org.locationtech.geomesa.core.transform
import org.geotools.process.vector.TransformProcess
import org.locationtech.geomesa.core.data.FeatureEncoding.FeatureEncoding
import org.locationtech.geomesa.core.data.{FeatureEncoding, SimpleFeatureEncoder}
import org.locationtech.geomesa.feature.{AvroSimpleFeature, Avr... |
Explain and rewrite the following Scala code: | // Copyright 2017 EPFL DATA Lab (data.epfl.ch)
//
// 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... |
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: | import org.apache.spark.mllib.util.MLUtils
val x = MLUtils.loadLibSVMFile (sc, "/home/robert/tmp/apache-spark-git/spark/data/mllib/sample_binary_classification_data.txt")
import java.io.PrintStream
val f = new PrintStream ("tmp.data")
val y = x.map (p => (p.label + " " + p.features.toDense.toArray.mkString (" ")))
v... |
Explain and rewrite the following Scala code: | package ru.org.codingteam.rotjs
import ru.org.codingteam.keter.scenes.IDisplay
import ru.org.codingteam.rotjs.interface.ROT.Display
package object wrappers {
implicit class RichDisplay(val self: Display) extends IDisplay {
override def draw(x: Int, y: Int, ch: String, fg: String, bg: String): Unit = self.draw... |
Explain and rewrite the following Scala code: | package com.softwaremill.aop
class FooWrapper(@delegate wrapped: Foo) extends Foo {
def method2(p1: String) = 41L
}
|
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 org.leialearns.crystallize.observations
import grizzled.slf4j.Logging
import java.util.concurrent.Semaphore
import org.leialearns.crystallize.event._
import org.leialearns.crystallize.event.History._
import org.leialearns.crystallize.item.Item
import org.leialearns.crystallize.model._
import java.util.concurre... |
Explain and rewrite the following Scala code: | // Copyright 2017 EPFL DATA Lab (data.epfl.ch)
//
// 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... |
Explain and rewrite the following Scala code: | package io.github.netvl.picopickle.backends.collections
import io.github.netvl.picopickle.ConvertersTestBase
class CollectionsConvertersTest extends ConvertersTestBase with CollectionsPickler {
override lazy val backendName: String = "collections"
}
|
Explain and rewrite the following Scala code: | package com.twitter.algebird.macros
import com.twitter.algebird._
import scala.language.experimental.macros
object caseclass {
implicit def semigroup[T]: Semigroup[T] = macro SemigroupMacro.caseClassSemigroup[T]
implicit def monoid[T]: Monoid[T] = macro MonoidMacro.caseClassMonoid[T]
implicit def group[T]: Grou... |
Explain and rewrite the following Scala code: | package diesel
import cats.Id
import org.scalatest.{FunSpec, Matchers}
class KtransSpec extends FunSpec with Matchers {
@ktrans
trait Maths[G[_]] {
def add(l: Int, r: Int): G[Int]
def subtract(l: Int, r: Int): G[Int]
def times(l: Int, r: Int): G[Int]
}
val MathsIdInterp = new Maths[Id] {
def... |
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 unfiltered.request
import scala.util.control.Exception.{ allCatch, catching }
trait DateParser extends (String => java.util.Date)
object DateFormatting {
import java.text.SimpleDateFormat
import java.util.{ Date, Locale, TimeZone }
def format(date: Date) =
new SimpleDateFormat("E, dd MMM yyyy HH:m... |
Explain and rewrite the following Scala code: | package models
/**
* Created by cschackerl on 23.07.2015.
*/
class AssociationRule(val support: Double, val confidence: Double, val lift: Double, val antecedent: Int, val consequent: Int) {
override def toString = s"AssociationRule ... support: $support, confidence: $confidence, lift: $lift, antecedent: $antecede... |
Explain and rewrite the following Scala code: | package scala.lms
package epfl
package test4
import common._
import test1._
import test2._
import test3._
/*
TODO:
+implement dfa_trans
+automata
+compile and run
benchmark
cleanup
parsing / tree construction?
http parser??
iteratee interface?
*/
/*
type NAutomaton[I,O] = List[NState[I,O]]
case class NState[I,O]... |
Explain and rewrite the following Scala code: | package com.mooveit.moonitor.principal
import akka.testkit.{TestProbe, TestActorRef}
import com.mooveit.moonitor.agent.actors.Agent.MetricCollected
import com.mooveit.moonitor.domain.alerts.AlertConfiguration
import com.mooveit.moonitor.domain.metrics.{MetricResult, MetricId}
import com.mooveit.moonitor.principal.acto... |
Explain and rewrite the following Scala code: | package tyckiting
trait Tyckiting extends Cli with Ai
|
Explain and rewrite the following Scala code: | package au.id.cxd.math.function.moments
/**
* empirical skewness assuming normality
* https://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm
* adjusted Fisher-Pearson coefficient of skewness
* G = \frac{\sqrt{N(N-1)}}{N-2} \frac{\sum_{i=1}^N(X_i - \bar{X})^3/N}{s^3}
*
* For standard normal distri... |
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 at.forsyte.apalache.tla.imp.passes
import at.forsyte.apalache.infra.ExceptionAdapter
import at.forsyte.apalache.infra.passes.{Pass, PassOptions, TerminalPassWithTlaModule, WriteablePassOptions}
import at.forsyte.apalache.tla.imp.ParserExceptionAdapter
import com.google.inject.AbstractModule
import com.google.i... |
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 2017 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.jetbrains.plugins.scala.base.libraryLoaders
import java.io.File
import com.intellij.openapi.module.Module
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.vfs.{JarFileSystem, VirtualFile}
import com.intellij.testFramework.PsiTestU... |
Explain and rewrite the following Scala code: | package spark_streaming
import org.apache.spark.Logging
import org.apache.log4j.{Level, Logger}
/**
* Created by asdf2014 on 2015/7/6.
*/
object StreamingExamples extends Logging {
/** Set reasonable logging levels for streaming if the user has not configured log4j. */
def setStreamingLogLevels() {
val log... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang
package psi
package api
package expr
import java.lang.UnsupportedOperationException
import com.intellij.psi.PsiElement
/**
* @author Alexander Podkhalyuzin
* Date: 06.03.2008
*/
trait ScPrefixExpr extends ScExpression with MethodInvocation with ScSugarCallExpr {
de... |
Explain and rewrite the following Scala code: | package esclient
import scala.collection.mutable
import org.elasticsearch.node.Node
import org.elasticsearch.common.settings.ImmutableSettings
import org.elasticsearch.node.NodeBuilder._
import play.api.{Configuration, Play}
object NodeHolder {
val nodes: mutable.ListBuffer[Node] = new mutable.ListBuffer[Node]()
... |
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: | import sbt.Keys._
import sbt.{Def, _}
object Tests {
import Configs._
private lazy val testSettings = Seq(
fork in Test := false,
parallelExecution in Test := false
)
private lazy val itSettings = inConfig(IntegrationTest)(Defaults.testSettings) ++ Seq(
fork in IntegrationTest := false,
paral... |
Explain and rewrite the following Scala code: | package co.ledger.wallet.web.ripple.core.database
import java.rmi.activation.ActivationGroup_Stub
import co.ledger.wallet.core.utils.HexUtils
import co.ledger.wallet.web.ripple.core.sjcl.SjclAesCipher
import co.ledger.wallet.web.ripple.core.webcrypto.WebCryptoCipher
import org.scalajs.dom.crypto.GlobalCrypto
import ... |
Explain and rewrite the following Scala code: | // Project: angulate2 (https://github.com/jokade/angulate2)
// Description:
// Copyright (c) 2016 Johannes.Kastner <jokade@karchedon.de>
// Distributed under the MIT License (see included LICENSE file)
package angulate2
import angulate2.internal.{AngulateBlackboxMacroTools, JSType}
import scala.lan... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012-2020 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 ap... |
Explain and rewrite the following Scala code: | package ildl
package benchmark
package hamming
package step2
import collection.mutable.Queue
// use java.lang.Long, so it doesn't get unboxed
import scala.{Long => _}
import java.lang.Long
//
// You can read about this benchmark on the following wiki page:
// https://github.com/miniboxing/ildl-plugin/wiki/Sample-%7E... |
Explain and rewrite the following Scala code: | package com.krux.hyperion
import com.krux.hyperion.common.{ NameGroupObjectId, RandomizedObjectId }
import org.scalatest.WordSpec
class PipelineObjectIdSpec extends WordSpec {
"RandomizedObjectId" should {
"generate a stable id" in {
val r = RandomizedObjectId("seed")
assert(r.toString == r.copy().... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2015 The Gravitee team (http://gravitee.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 requ... |
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.greencatsoft.angularjs
trait Config extends Service with Initializable
|
Explain and rewrite the following Scala code: | package com.twitter.finagle.factory
import com.twitter.conversions.time._
import com.twitter.finagle.{MockTimer, Service, ServiceFactory, ServiceTimeoutException}
import com.twitter.util.{Await, Future, Promise, Return, Time}
import org.specs.SpecificationWithJUnit
import org.specs.mock.Mockito
class TimeoutFactorySp... |
Explain and rewrite the following Scala code: | package com.github.atais.map
import java.util
import java.util.concurrent.ConcurrentHashMap
import scala.collection.GenSeq
/**
* Created by msiatkowski on 21.07.16.
*/
object MapRemoveBenchmark extends MapBenchmark {
performance of "Different Map implementations" config opts in {
measure method "remove" ... |
Explain and rewrite the following Scala code: | package ru.dgolubets.neo4s.model.stream
import ru.dgolubets.neo4s.model._
/**
* Base trait for streamed result
*/
sealed trait CypherStreamMessageBase
/**
* Base trait for streamed results visible to user.
*/
sealed trait CypherStreamMessage extends CypherStreamMessageBase
/**
* Commit uri.
* @param uri URI s... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka
import akka.actor._
/**
* == Commonly Used Patterns With Akka ==
*
* This package is used as a collection point for usage patterns which involve
* actors, futures, etc. but are loosely enough coupled to (multiple of) them
* t... |
Explain and rewrite the following Scala code: | package is.hail.expr.ir.agg
import breeze.linalg.{DenseMatrix, DenseVector, diag, inv}
import is.hail.annotations.{Region, RegionValueBuilder, StagedRegionValueBuilder, UnsafeRow}
import is.hail.asm4s._
import is.hail.expr.ir.{EmitClassBuilder, EmitCode, EmitCodeBuilder, EmitMethodBuilder}
import is.hail.types.physica... |
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 lila.chat
import chess.Color
import lila.user.{ Title, User }
sealed trait Line {
def text: String
def author: String
def deleted: Boolean
def isSystem = author == systemUserId
def isHuman = !isSystem
def humanAuthor = isHuman option author
def troll: Boolean
def userIdMaybe: Option[Us... |
Explain and rewrite the following Scala code: | package scalaSci.JBLAS
import java.util._
import Jama._
import org.jblas.DoubleMatrix._
import org.jblas.DoubleMatrix
import org.jblas.ComplexDoubleMatrix
import scalaSci.Vec
import scalaSci.math.LinearAlgebra.LinearAlgebra
import scalaSci.math.array.DoubleArray
// allows static methods of ScalaSci's mathematical ... |
Explain and rewrite the following Scala code: | package com.pauldoo.euler.puzzle
object Puzzle9 extends Puzzle {
def answer() = {
(for (
a <- 1 to 1000 / 3;
b <- (a + 1) to (1000 - a - 1) / 2;
val c = 1000 - a - b if a * a + b * b == c * c
) yield a * b * c).head
}
} |
Explain and rewrite the following Scala code: | /**
* FILE: LoadGlobalData.scala
* PERCORSO /Codice/sgad/servertier/src/main/scala/sgad/servertier/businesslogic/operations
* DATA CREAZIONE: 23 Febbraio 2014
* AUTORE: ProTech
* EMAIL: protech.unipd@gmail.com
*
* Questo file è proprietà del gruppo ProTech, viene rilasciato sotto licenza Apache v2.
*
* DIARIO ... |
Explain and rewrite the following Scala code: | // scalac: -Xfatal-warnings
//
object OhNoes {
sealed trait F
sealed abstract class FA extends F
sealed abstract class FB extends F
case object FA1 extends FA
case object FB1 extends FB
case object FB2 extends FB
sealed trait G
case object G1 extends G
case object G2 extends G
sealed trait H
c... |
Explain and rewrite the following Scala code: | package views.json.admin.User
import play.api.libs.json.{Json, JsValue}
import models.User
import models.pagination.Page
object index {
def apply(page: Page[User]) : JsValue = {
Json.obj(
"page" -> (1 + (page.pageInfo.request.offset / page.pageInfo.request.limit)),
"pageSize" -> page.pageInfo.reque... |
Explain and rewrite the following Scala code: | package au.edu.uq.html2docx
import org.scalatra._
import scalate.ScalateSupport
import org.docx4j.openpackaging.packages.WordprocessingMLPackage
import org.docx4j.convert.in.xhtml.XHTMLImporter
import java.io.FileInputStream
import java.io.StringReader
import scala.xml.XML
class MainServlet extends Html2docxDemoStack... |
Explain and rewrite the following Scala code: | package com.debasish.nlp.posTaggers
/**
* Created by Debasish Kaushik on 5/21/16.
*/
private[posTaggers] trait POSTagger {
def process(string: String): List[(String, String)]
}
object POSTagger {
private[this] val posTagger = new StanfordPOSTagger
def apply(string: String): List[(String, String)] = {
... |
Explain and rewrite the following Scala code: | package scala
package reflect
package internal
package transform
import Flags._
import scala.collection.mutable
trait UnCurry {
val global: SymbolTable
import global._
import definitions._
/**
* The synthetic Java vararg method symbol corresponding to a Scala vararg method
* annotated with @varargs.
... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2005, The Beangle Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This... |
Explain and rewrite the following Scala code: | package sgl.geometry
import org.scalatest.funsuite.AnyFunSuite
class EllipseSuite extends AnyFunSuite {
test("adds a Vec") {
val c = Ellipse(0, 0, 10, 20)
val v = Vec(1, 1)
val expected = Ellipse(1,1,10, 20)
assert(c + v === expected)
}
test("subtracts a Vec") {
val c = Ellipse(0, 0, 10, 2... |
Explain and rewrite the following Scala code: | package com.dwolla.cloudflare.domain.dto.accounts
import io.circe.Codec
import io.circe.generic.semiauto.deriveCodec
case class AccountMemberDTO (
id: String,
user: UserDTO,
status: String,
roles: Seq[AccountRoleDTO]
)
object AccountMemberDTO {
implicit val accountMemberDTOCodec: Codec[AccountMemberDTO] = ... |
Explain and rewrite the following Scala code: | /** Copyright 2015 TappingStone, 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 ... |
Explain and rewrite the following Scala code: | package lila.db
import dsl._
object Util {
def findNextId(coll: Coll): Fu[Int] =
coll.find($empty, $id(true))
.sort($sort desc "_id")
.uno[Bdoc] map {
_ flatMap { doc => doc.getAs[Int]("_id") map (1+) } getOrElse 1
}
}
|
Explain and rewrite the following Scala code: | object SCL6507 {
import scala.Product2
object patternMatchingProduct {
class MyProduct(one: String, two: Int) extends Product2[String, Int] {
def _1 = one
def _2 = two
def canEqual(that: Any): Boolean = ???
}
object MyProduct {
def apply(one: String, two: Int) = new MyProduc... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
package core.health
import com.wix.accord.validate
import mesosphere.UnitTest
import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol
import mesosphere.marathon.api.v2.ValidationHelper
import mesosphere.marathon.core.instance.Instance.AgentInfo
import mesosphere.marathon.core.insta... |
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: | package chrome.browserAction.bindings
import scala.scalajs.js
@js.native
trait TabIdDetails extends js.Object {
val tabId: js.UndefOr[Int] = js.native
}
object TabIdDetails {
def apply(tabId: js.UndefOr[Int] = js.undefined): TabIdDetails = {
js.Dynamic
.literal(
tabId = tabId
)
.asI... |
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 not u... |
Explain and rewrite the following Scala code: | package org.scalacoin.script.arithmetic
import org.scalacoin.script.constant.ScriptOperation
/**
* Created by chris on 1/6/16.
*/
sealed trait ArithmeticOperation extends ScriptOperation
/**
* 1 is added to the input.
*/
case object OP_1ADD extends ArithmeticOperation {
override def opCode = 139
}
/**
* 1 i... |
Explain and rewrite the following Scala code: | package breeze.stats.distributions
/*
Copyright 2014 Jacob Andreas
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 applicab... |
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 provingground.learning
import provingground._, HoTT._, induction._
import scala.collection.parallel._
import shapeless._, HList._
import TermRandomVars._, TermGeneratorNodes._
import scala.collection.parallel.immutable.ParVector
import ParMapState._
import scala.collection.mutable.ArrayBuffer
case class Par... |
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 odfi.h2dl.indesign.h2dl
import nx.NXObject
import tcl.integration.TclObject
import tcl.TclInterpreter
/**
* @author zm4632
*/
class H2DLObject(interpreter: TclInterpreter, obj: TclObject) extends NXObject(interpreter, obj) {
}
object H2DLObject {
implicit def NXObjectToH2DLObject(nx:NXObject) : H2D... |
Explain and rewrite the following Scala code: | package com.arcusys.learn.liferay.update.version300
import com.arcusys.learn.liferay.LiferayClasses.LUpgradeProcess
import com.arcusys.learn.liferay.update.SlickDBContext
import com.arcusys.learn.liferay.update.version300.migrations.CertificateGoalMigration
import com.arcusys.valamis.web.configuration.ioc.Configuratio... |
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 scutil.lang
import scutil.lang.tc._
object IoDisposer {
def delay(block: =>Unit):IoDisposer =
IoDisposer(Io delay block)
/** forms a monoids with combine */
val empty:IoDisposer = IoDisposer(Io.unit)
def combineAll(subs:Iterable[IoDisposer]):IoDisposer =
subs.foldLeft(empty)(_ combine _)
def combi... |
Explain and rewrite the following Scala code: | /*
* Copyright 2010-2014 Benjamin Lings
*
* 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 io.hydrosphere.mist
import org.scalatest.{FunSpec, Matchers}
class ExamplesSpecSpark1 extends FunSpec with MistItTest with Matchers {
if (isSpark1) {
val interface = MistHttpInterface("localhost", 2004)
it("run simple context") {
val result = interface.runJob("simple-context",
"num... |
Explain and rewrite the following Scala code: |
object Test {
def main(args: Array[String]): Unit = {
println("CaseNums")
test(CaseNums)
println()
println("IntNums")
test(IntNums)
}
def test(numbers: Numbers) = {
import numbers.*
val zero: Nat = Zero()
val one: Nat = Succ(zero)
val two: Nat = Succ(one)
val t... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2005, The Beangle Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This... |
Explain and rewrite the following Scala code: | package a {
abstract class BoxingConversions[Boxed, Unboxed] {
def box(x: Unboxed): Boxed
def unbox(x: Boxed): Unboxed
}
class Meter(val underlying: Double) extends AnyVal with _root_.b.Printable {
def + (other: Meter): Meter =
new Meter(this.underlying + other.underlying)
def / (other: Met... |
Explain and rewrite the following Scala code: | /******************************************************************************
* Copyright (c) 2014, Equal Experts Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of ... |
Explain and rewrite the following Scala code: | package db
import java.util.UUID
import io.flow.delta.v0.models.{OrganizationSummary, ProjectSummary, Visibility}
import io.flow.postgresql.Authorization
import io.flow.test.utils.FlowPlaySpec
class ItemsDaoSpec extends FlowPlaySpec with Helpers {
private[this] lazy val org = createOrganization()
"replace" in ... |
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: | class TestEmail {
def getDomain(e: EmailAddress): String = e.domainPart
def run: Unit =
val em = EmailAddress("a@b.c")
assert(getDomain(em) == "b.c")
}
|
Explain and rewrite the following Scala code: | package aecor.tests
import java.time._
import aecor.data.Folded
import aecor.schedule.ScheduleEvent.{ ScheduleEntryAdded, ScheduleEntryFired }
import aecor.schedule.{ DefaultScheduleBucket, ScheduleState }
import cats.Id
import cats.data.Chain
import org.scalatest.matchers.should.Matchers
import org.scalatest.flatspe... |
Explain and rewrite the following Scala code: | package skuber.json
import org.specs2.execute.{Failure, Result}
import org.specs2.mutable.Specification
import play.api.libs.json._
import skuber._
import skuber.json.format._
import scala.io.Source
import skuber.PersistentVolumeClaim.VolumeMode
/**
* @author David O'Riordan
*/
class VolumeReadWriteSpec extends Sp... |
Explain and rewrite the following Scala code: | package ac.ncic.syssw.pppuc03
def sort(xs: Array[Int]) {
def swap(i: Int, j: Int) {
val t = xs(i); xs(i) = xs(j); xs(j) = t;
// () // pronounced as "unit"
}
def sortImpl(l: Int, r: Int) {
val pivot = xs((l + r) / 2)
var i = l; var j = r;
while (i <= j) {
while (xs(i) < pivot) i += 1
... |
Explain and rewrite the following Scala code: | import org.specs2.mutable.Specification
object OAuthSpec extends Specification {
import dispatch.classic._
import oauth._
import Request._
import OAuth._
val svc = :/("term.ie") / "oauth" / "example"
val consumer = Consumer("key", "secret")
"OAuth test host" should {
"echo parameters from prote... |
Explain and rewrite the following Scala code: | /*
* La Trobe University - Distributed Deep Learning System
* Copyright 2016 Matthias Langer (t3l@threelights.de)
*
* 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.apa... |
Explain and rewrite the following Scala code: | /*****************************************************************************
* Schip8: A Chip-8 Emulator
* Copyright (C) 2014, S. Nizar <nisehl at gmail dot com>
*
* Instructions.scala:
* Opcodes and operands implementations for executing
* instructions
********************... |
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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.