instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package spire.math.algebraic
/**
* A mixin for a `Real` that let's us transform the tree as its being built.
* In your implementation of `transform`, you'll likely want to play nice and
* call `super.transform(x)` first.
*/
trait RealTransform[A <: RealLike[A]] extends RealLike[A] { self: A =>
/**
* Override ... |
Explain and rewrite the following Scala code: | //import com.caibowen.gplume.misc.testing.junit.ManifestPath
//import _root_.com.caibowen.gplume.scala.context.AppContext
//import org.junit.Test
//import org.junit.runner.RunWith
//
///**
//* @author BowenCai
//* @since 10/12/2014.
//*/
//@RunWith(classOf[_root_.com.caibowen.gplume.scala.misc.testing.JunitPal])
//@Ma... |
Explain and rewrite the following Scala code: | package breeze.io
import java.io._
import au.com.bytecode.opencsv.{CSVReader => OpenCSVReader, CSVWriter=>OpenCSVWriter}
/**
* Just a simple wrapper for OpenCSV's csvreader.
* @author dlwh
*/
object CSVReader {
def read(input: Reader,
separator: Char=',',
quote: Char='"',
escape... |
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 spire
package math
package poly
import java.lang.Integer.{ numberOfLeadingZeros, numberOfTrailingZeros }
import spire.algebra.{Eq, Field, Ring, Rng, Semiring}
import spire.math.Polynomial
import spire.std.int._
import spire.syntax.field._
import spire.syntax.eq._
import spire.syntax.cfor._
import spire.synta... |
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 Red Hat, Inc.
*
* Red Hat licenses this file to you 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... |
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 dotty.tools.dotc
package transform
import core._
import DenotTransformers.SymTransformer
import Phases.Phase
import Contexts.Context
import SymDenotations.SymDenotation
import TreeTransforms.MiniPhaseTransform
import Flags._, Symbols._
/** 1. Widens all private[this] and protected[this] qualifiers to just pri... |
Explain and rewrite the following Scala code: | package com.geishatokyo.diffsql.parser
import com.geishatokyo.diffsql.Definition
import com.geishatokyo.diffsql.ast.Comment
import org.scalatest.{Matchers, FlatSpec}
/**
* Created by takeshita on 2014/11/11.
*/
class SkipCommentTest extends FlatSpec with Matchers {
object LitralParser extends SQLParser{
over... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2009 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 com.gu.mobile.notifications.football.models
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
class MatchPhaseEventSpec extends Specification with Mockito {
"MatchPhaseEvent" should {
"Create a Kickoff event from timeline event 0:00" in {
val event = mock[pa.MatchEvent]
... |
Explain and rewrite the following Scala code: | import org.specs2.mutable._
class HelloWorldSpec extends Specification {
"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
}
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
}
"end with 'world'" in {
"Hello world" m... |
Explain and rewrite the following Scala code: | package com.github.jirotubuyaki.main.scala.Need
import com.github.jirotubuyaki.main.scala.Market._
import com.github.jirotubuyaki.main.scala.Company._
import com.github.jirotubuyaki.main.scala.Product._
import com.github.jirotubuyaki.main.scala.Customer._
import com.github.jirotubuyaki.main.scala.Need._
import java.io... |
Explain and rewrite the following Scala code: | package org.reactivecouchbase.client
import net.spy.memcached.{ReplicateTo, PersistTo}
/**
* Some constants
*/
object Constants {
/**
* Infinity persistence
*/
val expiration: Int = 0
/**
* Standard PersistTo
*/
implicit val defaultPersistTo: PersistTo = PersistTo.ZERO
/**
* Standard Rep... |
Explain and rewrite the following Scala code: | package com.dividezero.stubby.test.support
import unfiltered.netty.Http
import com.dividezero.stubby.standalone.{AppPlan, Server}
import unfiltered.util.StartableServer
/*
* Simple test server using standalone implementation
*/
object TestServer {
val server = new Server(Nil)
var http: StartableServer = null
... |
Explain and rewrite the following Scala code: | package org.scalaide.core.internal.decorators.markoccurrences
import org.scalaide.core.compiler.InteractiveCompilationUnit
import org.scalaide.logging.HasLogger
import scala.reflect.internal.util.SourceFile
import scala.tools.refactoring.analysis.GlobalIndexes
import scala.tools.refactoring.implementations.MarkOccurre... |
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.kifi.lda
import scala.io.Source
import scala.collection.mutable.ListBuffer
trait DocIterator {
def hasNext: Boolean
def next: Doc
def gotoHead(): Unit
def getPosition(): Int
}
class OnDiskDocIterator(fileName: String) extends DocIterator {
private var lineIter = Source.fromFile(fileName).getLin... |
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 breeze.numerics
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
*
* @author dlwh
*/
@RunWith(classOf[JUnitRunner])
class ScalingTest extends FunSuite {
test("Simple Test, big") {
val array = Array(math.pow(2,300), math.pow(2, 301), math.pow(2,... |
Explain and rewrite the following Scala code: | import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-feature -language:_"
def code = """
:type 42
val x: 23 = 23
:type x
:type (23: 23)
val y = x
:type y
final val z = x
:type z
def xx: 23 = 23
:type xx
final val yy = xx
:type yy
""".trim
}
|
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 java.util.function
@FunctionalInterfa... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang
package parser
package parsing
import builder.ScalaPsiBuilder
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes
import org.jetbrains.plugins.scala.lang.parser.util.ParserUtils
import com.intell... |
Explain and rewrite the following Scala code: | package ulang.expr
import java.io._
import scala.language.postfixOps
import arse._
import arse.implicits._
import sourcecode.Name
object operators extends Syntax[Id] {
def is_mixfix_op(id: Id): Boolean = {
contains(id) || is_bind_op(id)
}
def is_bind_op(id: Id) = {
bind_ops contains id
}
var d... |
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: | /*
* 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 pages.vrm_assign
import org.openqa.selenium.WebDriver
import org.scalatest.selenium.WebBrowser.{find, id}
import uk.gov.dvla.vehicles.presentation.common.helpers.webbrowser.{Page, WebDriverFactory}
import uk.gov.dvla.vehicles.presentation.common.views.widgets.MicroServiceError.{ExitId, TryAgainId}
object Micr... |
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: | import play.api.libs.iteratee._
import reactivemongo.api._
import reactivemongo.api.gridfs.{ ReadFile, DefaultFileToSave, GridFS }
import reactivemongo.api.gridfs.Implicits._
import reactivemongo.bson._
import scala.concurrent._
import reactivemongo.api.gridfs
import scala.concurrent.duration._
object GridfsSpec exten... |
Explain and rewrite the following Scala code: | // - Project: scalajs-angulate (https://github.com/jokade/scalajs-angulate)
// Description: API for Angular $animate service
//
// Distributed under the MIT License (see included file LICENSE)
package biz.enef.angulate.core
import org.scalajs.dom.Element
import scala.scalajs.js
/**
* API for Angular \\$animate se... |
Explain and rewrite the following Scala code: | trait Expr[T]
trait Liftable[T]
object test1 {
class ToExpr[T](using Liftable[T]) extends Conversion[T, Expr[T]] {
def apply(x: T): Expr[T] = ???
}
given toExprFun[T](using Liftable[T]): ToExpr[T] with {}
given Liftable[Int] = ???
given Liftable[String] = ???
def x = summon[ToExpr[String]]
def y = ... |
Explain and rewrite the following Scala code: | /*******************************************************************************
* Copyright 2010 Olaf Sebelin
*
* This file is part of Verdandi.
*
* Verdandi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Found... |
Explain and rewrite the following Scala code: | package com.tribbloids.spookystuff.python.ref
trait NoneRef extends PyRef {
override final val referenceOpt = Some("None")
override final val delOpt = None
}
|
Explain and rewrite the following Scala code: | package org.scalamu.core
import org.scalamu.core.api.DetectionStatusImplicits
package object testapi extends TestSuiteResultImplicits with DetectionStatusImplicits
|
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.arcusys.learn.controllers.views
import scala.collection.JavaConversions._
import javax.portlet.GenericPortlet
import javax.portlet.PortletContext
import javax.servlet.ServletContext
import org.scalatra._
import java.util.Properties
import java.io.{ FileInputStream, InputStreamReader }
trait i18nSupport {
... |
Explain and rewrite the following Scala code: | import sbt._
import sbt.Keys._
object Build extends Build {
// factor out common settings into a sequence
lazy val commonSettings = Seq(
organization := "com.chunlianglyu.sorm2",
version := "0.4.3",
// set the Scala version used for the project
scalaVersion := "2.11.7"
)
lazy val root = Projec... |
Explain and rewrite the following Scala code: | package com.monsanto.arch.cloudformation.model
import org.scalatest.{FunSpec, Matchers}
import spray.json._
import DefaultJsonProtocol._
class FnGetAZs_UT extends FunSpec with Matchers {
describe("Fn::GetAZs") {
it("should serialize correctly") {
val p = StringParameter("pAZ")
val c = Condition("cA... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang
package psi
package stubs
package impl
import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.{IStubElementType, StubElement}
import org.jetbrains.plugins.scala.lang.psi.api.statements.params.ScParameters
/**
* User: Alexander Podkhalyuzin
* Date: 19.10.200... |
Explain and rewrite the following Scala code: | /*
* ____ ____ _____ ____ ___ ____
* | _ \\ | _ \\ | ____| / ___| / _/ / ___| Precog (R)
* | |_) | | |_) | | _| | | | | /| | | _ Advanced Analytics Engine for NoSQL Data
* | __/ | _ < | |___ | |___ |/ _| | | |_| | Copyright (C) 2010 - 2013 SlamData, In... |
Explain and rewrite the following Scala code: | package genericList
import cats.Functor
import cats.data.Func
// code borrowed from:
// http://eed3si9n.com/herding-cats/datatype-generic-programming.html
// see also usefull resources:
// https://dzone.com/articles/datatype-generic-programming
sealed abstract class Fix[S[_], A] extends Serializable {
def out: S[F... |
Explain and rewrite the following Scala code: | package pb.backend
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.{Directives, Route}
import akka.stream.ActorMaterializer
import pb.backend.infrastructure.twirl._
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success}
class Api extends Directives... |
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: | /**
* This file is part of the TA Buddy project.
* Copyright (c) 2013-2014 Alexey Aksenov ezh@ezh.msk.ru
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Global License version 3
* as published by the Free Software Foundation with the addition... |
Explain and rewrite the following Scala code: | class I {
object A1
object A2
object A3
object A4
object A5
object A6
object A7
object A8
object A9
object A10
object A11
object A12
object A13
object A14
object A15
object A16
object A17
object A18
}
object Test {
def main(args: Array[String]): Unit = {
val c = new I
impo... |
Explain and rewrite the following Scala code: | package nexus
/**
* Typeclass representing the ability to construct conditional (if-then-else) expressions.
* @tparam B Type of conditions (a canonical version would be [[Boolean]])
* @tparam F Higher-kinded type of supported `then`/`else` clauses
* @author Tongfei Chen
* @since 0.1.0
*/
trait Cond[B, F[_]] {
... |
Explain and rewrite the following Scala code: | package uk.gov.gds.ier.transaction.ordinary.previousAddress
import com.google.inject.Inject
import uk.gov.gds.ier.config.Config
import uk.gov.gds.ier.model._
import uk.gov.gds.ier.security.EncryptionService
import uk.gov.gds.ier.serialiser.JsonSerialiser
import uk.gov.gds.ier.step.OrdinaryStep
import uk.gov.gds.ier.st... |
Explain and rewrite the following Scala code: | package com.sunnymix.academydb.utils.disruptor.samples
import com.lmax.disruptor.EventFactory
/**
* @author Sunny
* @since 2017-7-23
*/
case class LongEvent(value: Long)
class LongEventFactory extends EventFactory[LongEvent] {
override def newInstance(): LongEvent = {
LongEvent(0L)
}
}
class HelloD... |
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 skinny.engine
import javax.servlet.http.{ HttpServletRequest, HttpServletResponse }
/**
* SkinnyEngine handler for gzipped responses.
*/
trait ContentEncodingSupport extends Handler { self: SkinnyEngineBase =>
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse): Unit = {
w... |
Explain and rewrite the following Scala code: | import compiletime.uninitialized
class Memo[A](x: => A):
private var cached: A = _ // error
private var known: Boolean = false
def force =
if !known then
known = true
cached = x
cached
|
Explain and rewrite the following Scala code: | /*
* This file is part of the \\BlueLaTeX 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 fr.xebia.xke
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
object Main extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val routes = Routes.routes
// TODO
// Démarrer le server en local sur le port 8080 avec l'objet routes ci-de... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2019 Israel Herraiz <isra@herraiz.org>
*
* 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, c... |
Explain and rewrite the following Scala code: | import leon.instrumentation._
import leon.invariant._
object ForElimination {
sealed abstract class List
case class Nil() extends List
case class Cons(head: Statement, tail: List) extends List
sealed abstract class Statement
case class Print(msg: BigInt, varID: BigInt) extends Statement
case class Assig... |
Explain and rewrite the following Scala code: | /*******************************************************************************
Copyright (c) 2013-2014, S-Core, KAIST.
All rights reserved.
Use is subject to license terms.
This distribution may include materials developed by third parties.
*********************************************************... |
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.scalableQuality.quick.mantle.constructFromXml
import com.scalableQuality.quick.mantle.error.UnrecoverableError
import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
import scala.xml.{Attribute, MetaData}
class AttributesValuesExtractor(
attributesMap: Map[AttributeValueExtracto... |
Explain and rewrite the following Scala code: | package com.softwaremill.mqperf.mq
class DummyMq(configMap: Map[String, String]) extends Mq {
override type MsgId = String
override def createSender() = new MqSender {
override def send(msgs: List[String]) {}
}
override def createReceiver() = new MqReceiver {
override def receive(maxMsgCount: Int) = ... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.autoImport
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.{PsiDocCommentOwner, PsiElement, PsiPackage}
import org.jetbrains.plugins.scala.autoImport.quickFix.ElementToImport
import org.jetbrains.plugins.scala.extensions.{ContainingFile, ObjectExt, PsiElemen... |
Explain and rewrite the following Scala code: | package hex
package format
/**
* O O O O O O O
* O O O O O O O
* O O R O O O O
* O O O R B O O
* O O O B O O O
* O O O O O O O
* O O O O O O O
* O O O O O O O
*/
object Visual {
//TODO
/*def <<(source: String): Board = {
val lines = source.lines.toList
val size = lines... |
Explain and rewrite the following Scala code: | package com.mec.scala
object MixinTest {
def main(args: Array[String])={
1 to 3 foreach (i => println(s"Result: ${service2.work(i)}"))
}
val service2 = new ServiceImportance("dos") with StdoutLogging{
override def work(i: Int) :Int = {
info(s"Starting work: i = $i")
val result = supe... |
Explain and rewrite the following Scala code: | package graphite.relay.server
import javax.inject.Singleton
import javax.inject.Inject
import org.apache.log4j.Logger
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.channel.Channel
import org.jboss.netty.channel.ChannelFutureListener
import org.jboss.netty.channel.ChannelHandlerContext
import or... |
Explain and rewrite the following Scala code: | package io.skyfii.mandrill.model
case class RecipientMetadata(rcpt: String, values: Map[String, String])
|
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 hello
import org.springframework.context.annotation.Configuration
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.Reque... |
Explain and rewrite the following Scala code: | package org.scalatest
@DoNotDiscover
class ExampleBeforeAfterParallelSpec extends FunSpec with BeforeAndAfter with ParallelTestExecution {
before {
info("In Before")
}
describe("Thing 1") {
it ("do thing 1a") {}
it ("do thing 1b") {}
it ("do thing 1c") {}
}
describe("Thing 2") {
it ... |
Explain and rewrite the following Scala code: | package io.hydrosphere.mist.master.security
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{Future, Promise}
import scala.util.{Failure, Success, Try}
import sys.process._
object KInitLauncher {
val NOPProcessLogger = new ProcessLogger {
override def buffer[T](f: => T): T = f
over... |
Explain and rewrite the following Scala code: | package com.github.chaabaj.openid.oauth
import com.github.chaabaj.openid.oauth
trait OAuthClient {
type Provider <: oauth.Provider
}
|
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2015-2016 DANS - Data Archiving and Networked Services (info@dans.knaw.nl)
*
* 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/LICENS... |
Explain and rewrite the following Scala code: | package controllers
import java.util.UUID
import javax.inject.Inject
import dal.ThingsRepository
import models.{Link, ThingType, ThingsPage, ThingsPageLinks}
import play.api.libs.json.Json
import play.api.mvc.{AbstractController, ControllerComponents}
import scala.concurrent.ExecutionContext
class ThingsController ... |
Explain and rewrite the following Scala code: | package com.translationdata
import org.junit.Assert._
import org.junit.Test
import scala.annotation.tailrec
class P01 {
@Test
def P01_last1():Unit = {
val result = P01.P01_last1(P01.numList)
assertEquals(7, result)
printf("P01_last1: %d%n", result)
}
@Test
def P01_last2():Unit = {
val resu... |
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"); yo... |
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 org.scalajs.testinterface
import language.experimental.macros
/** Dummy object to get the right shadowing for 2.10 / 2.11 cross compilation */
private object Compat210 {
object blackbox {
type Context = scala.reflect.macros.Context
}
}
import Compat210._
object TestUtils {
import scala.reflect.mac... |
Explain and rewrite the following Scala code: | package breeze.linalg
/*
Copyright 2012 David Hall
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 com.github.kimutansk.akka.exercise.persistence
import akka.actor.{ActorDSL, Props, ActorSystem}
import com.github.kimutansk.akka.exercise.routing.MessagePrintActor
import java.util.concurrent.TimeoutException
import akka.routing.FromConfig
import com.typesafe.config.ConfigFactory
import com.github.kimutansk.ak... |
Explain and rewrite the following Scala code: | package cromwell.util
import java.io.{File, FileInputStream, Writer}
import java.nio.file.Path
import better.files._
import org.apache.commons.codec.digest.DigestUtils
import wdl4s.values.Hashable
import scala.collection.immutable.Queue
import scala.util.{Failure, Success, Try}
object FileUtil {
def swapExt(fileP... |
Explain and rewrite the following Scala code: | package io.taig.android.graphic.operation
import scala.math.Integral.Implicits._
import scala.math.Ordering.Implicits._
import scala.math.{max, min}
import io.taig.android.graphic.Dimension
final class dimension[T: Integral](dimension: Dimension[T]) {
/**
* Aspect ration of this Resolution
*
* @return ... |
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 net.sansa_stack.rdf.spark.partition.graph.evaluation
import net.sansa_stack.rdf.spark.partition.graph.algo.PartitionAlgo
import scala.reflect.ClassTag
/**
* Evaluator for partition strategy.
*
* @param ps Partition Strategy
* @tparam VD the vertex attribute associated with each vertex in the set.
* @tpa... |
Explain and rewrite the following Scala code: | package gg.uhc.hosts.endpoints
import akka.http.scaladsl.server.Rejection
case class MissingIpErrorRejection() extends Rejection
|
Explain and rewrite the following Scala code: | /*
* Licensed to Tuplejump Software Pvt. Ltd. under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Tuplejump Software Pvt. Ltd. licenses this file
* to you under the Apache License, Version 2.0 (the
* "Li... |
Explain and rewrite the following Scala code: | package org.talkingpuffin.ui.filter
import swing._
import scala.swing.GridBagPanel._
import java.awt.event.KeyEvent
import javax.swing.border.EmptyBorder
import org.talkingpuffin.filter.NoiseFilter
/**
* The General pane of the Filters dialog.
*/
class GeneralPane extends GridBagPanel {
border = new EmptyBorder(5... |
Explain and rewrite the following Scala code: | package eventstore
package core
package operations
import ScavengeError._
import Inspection.Decision._
private[eventstore] object ScavengeDatabaseInspection
extends ErrorInspection[ScavengeDatabaseResponse, ScavengeError] {
def decision(error: ScavengeError) = {
val result = error match {
case InProg... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 Steve Vickers
*
* 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 fpscala
object Sorts {
import scala.math.Ordered
def quickSort[T <% Ordered[T]](xs: List[T]): List[T] = xs match {
case Nil => Nil
case x :: rest => {
val (before, after) = rest partition { _ < x }
quickSort(before) ++ (x :: quickSort(after))
}
}
def mergeSort[T <% Ordered[T]]... |
Explain and rewrite the following Scala code: | /**
* (c) Copyright 2013 WibiData, Inc.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* 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... |
Explain and rewrite the following Scala code: | package com.arcusys.valamis.content.export.model
case class QuestionCategoryExport(title: String,
description: String,
children: Seq[QuestionExport],
childrenCats: Seq[QuestionCategoryExport],
... |
Explain and rewrite the following Scala code: | package cn.itcast
/**
*资源代码
*
*/
object Main4 {
def main(args: Array[String]) {
def f2(x: Int) = x * 2
val f3 = (x: Int) => x * 3
val f4: (Int) => Int = { x => x * 4 }
val f4a: (Int) => Int = _ * 4
val f5 = (_: Int) * 5
val list = List(1, 2, 3, 4, 5)
var new_list: List[... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017 Magomed Abdurakhmanov, Hypertino
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
package com.hypertino.hyperbus.model.annotations
im... |
Explain and rewrite the following Scala code: | import sbt.Keys._
import sbt._
import uk.gov.hmrc.SbtAutoBuildPlugin
import uk.gov.hmrc.versioning.SbtGitVersioning
object HmrcBuild extends Build {
import BuildDependencies._
import uk.gov.hmrc.DefaultBuildSettings._
val appName = "$!APP_NAME!$"
lazy val $!APP_NAME_UNDERSCORE_ONLY!$ = Project(appName, fil... |
Explain and rewrite the following Scala code: | package com.github.aselab.activerecord.io
import org.specs2.mock._
import com.github.aselab.activerecord._
import dsl._
import models._
import validations._
import java.util.{Date, UUID}
import java.sql.Timestamp
object IOSpec extends DatabaseSpecification with Mockito {
case class ListModel(l1: List[String], l2: ... |
Explain and rewrite the following Scala code: | /*
* OpenUniverseTest.scala
* Open universe example test.
*
* Created By: Avi Pfeffer (apfeffer@cra.com)
* Creation Date: Jan 1, 2009
*
* Copyright 2013 Avrom J. Pfeffer and Charles River Analytics, Inc.
* See http://www.cra.com or email figaro@cra.com for information.
*
* See http://www.github.co... |
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.http4s.server.middleware
import cats.data.{Kleisli, OptionT}
import cats.effect.{Clock, ExitCase, Sync}
import cats.effect.implicits._
import cats.implicits._
import fs2.Stream
import java.util.concurrent.TimeUnit
import org.http4s._
import org.http4s.metrics.MetricsOps
import org.http4s.metrics.Terminatio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.