instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
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 week3
import week3.intsets._
object IntSetsTesting {;import org.scalaide.worksheet.runtime.library.WorksheetSupport._; def main(args: Array[String])=$execute{;$skip(107);
val set1 = new NonEmpty(3, Empty, Empty);System.out.println("""set1 : week3.NonEmpty = """ + $show(set1 ));$skip(24);
val set2 = s... |
Explain and rewrite the following Scala code: | package com.microsoft.awt.routes
import org.scalajs.nodejs.mongodb.{Db, MongoDB}
import org.scalajs.nodejs.console
import org.scalajs.nodejs.express.{Application, Request}
import org.scalajs.nodejs.expressws.{WS, WsInstance, WsRouting}
import scala.concurrent.{ExecutionContext, Future}
import scala.scalajs.js
import ... |
Explain and rewrite the following Scala code: | package com.ponkotuy.data
import org.json4s._
import com.ponkotuy.tool.{DateFormatLocal, Pretty}
import java.util.Date
/**
*
* ID is not unique. ID is Dock Number(1-4).
*
* @author ponkotuy
* Date: 2014/03/01.
*/
case class NDock(id: Int, shipId: Int, completeTime: Long) {
import NDock._
def summary: String... |
Explain and rewrite the following Scala code: | // !< 特质....
// !< 关键字:trait
trait Philosophical
{
def philosophize()
{
println("I consume memory, therefore I am!")
}
}
// !< 特质的'混入'
class Frog extends Philosophical
{
override def toString = "green"
}
frog = new Frog
frog.philosophize()
// !< 特质的'混入'2
class Animal
trait HasLegs
class Frog2 extends Animal wi... |
Explain and rewrite the following Scala code: | object DigitProblem extends App {
val in = io.Source.stdin.getLines()
val Array(x, kString) = in.next.split(" ")
val k = kString.toInt
var count = 0
println(x.map(x => {
if(count < k && x != '9'){
count += 1
'9'
}else{
x
}
}))
}
|
Explain and rewrite the following Scala code: | class a {
try {
} <caret>
catch {
}
}
/*
*/ |
Explain and rewrite the following Scala code: | package scala.meta
import scala.meta.internal.hosts.scalac.contexts.{Compiler => Compiler}
import scala.meta.internal.hosts.scalac.contexts.{Proxy => ProxyImpl}
object Mirror {
def apply(artifacts: Artifact*)(implicit taxonomy: TaxonomicContext): Mirror = {
// TODO: In the future, we may avoid instantiating the... |
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: | /* scala-stm - (c) 2009-2010, Stanford University, PPL */
package scala.concurrent.stm
import java.util.concurrent.CyclicBarrier
import org.scalatest.{FunSuite, Tag}
class HistogramSuite extends FunSuite {
for ((opsPerTest, name, slow) <- List((10000, "10K", false),
(10000... |
Explain and rewrite the following Scala code: | package com.workingtheory.scala
import org.apache.logging.log4j.{LogManager, Logger}
/**
* This class demonstrates creation of class level 'static' method and object level method in Scala
* and print a hello world using the created methods.
*/
class Methods
{
private val logger: Logger = LogManager.getLogger(M... |
Explain and rewrite the following Scala code: | package net.walend.intro2scala
import net.walend.present.{CodeSyntax, CodeBlock, LinkTextLine, LinkFragment, TextFragment, FragmentLine, Style, TextLine, SimpleSlide}
import net.walend.present.Shortcuts._
/**
* @author david
*/
object ProsAndCons {
val Pros = SimpleSlide("Pros",
t("Scala - Pros"),
Text... |
Explain and rewrite the following Scala code: | val subset = for {
s <- Set("a", "b", "c")
if(/*start*/s.compareTo("c")/*end*/ < 0)
} yield s
//Int |
Explain and rewrite the following Scala code: | package net.spals.appbuilder.app.finatra
import com.google.inject.name.Names
import com.google.inject.{Key, Stage, TypeLiteral}
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.annotations.FlagImpl
import io.opentracing.{NoopTracer, Tracer}
import net.spals.appbuilder.app.examples.finatra.s... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ma... |
Explain and rewrite the following Scala code: |
package views.html.climate
import play.templates._
import play.templates.TemplateMagic._
import play.api.templates._
import play.api.templates.PlayMagic._
import models._
import controllers._
import java.lang._
import java.util._
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
impo... |
Explain and rewrite the following Scala code: | package biz.meetmatch.util
import java.io.{File, InputStream}
import java.text.SimpleDateFormat
import java.util.concurrent.TimeUnit
import java.util.{Calendar, Date}
import biz.meetmatch.logging.BusinessSparkListener
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.commons.io.FileUtils
import org... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 The Guardian
*
* 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) 2017 Ben Zimmer. All rights reserved.
package bdzimmer.pixeleditor.view
import scala.collection.mutable.Buffer
import javax.swing.{JTextField, JComboBox, JOptionPane}
import bdzimmer.pixeleditor.model.TileCollectionModel._
import bdzimmer.pixeleditor.model.{Color, TileProperties, TileContainer}
imp... |
Explain and rewrite the following Scala code: | package troy
package driver
/**
* Represents Cassandra Types
* To be used as Type parameters, not for instantiation
*/
sealed trait CassandraDataType
object CassandraDataType {
sealed trait Native extends CassandraDataType
final class Ascii private () extends Native
final class BigInt private () extends Nativ... |
Explain and rewrite the following Scala code: | import scala.util._
object PaintCan{
val codes = Map[String,String](
"end" ->"\u001b[0", // Text Reset
"Black" ->"30",
"Red" ->"31",
"Green" ->"32",
"Yellow" ->"33",
"Blue" ->"34",
"Purple" ->"35",
"Cyan" ->"36",
"White" ->"37",
... |
Explain and rewrite the following Scala code: | package hulk
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Flow
import cats.data.Xor
import com.codahale.metrics.MetricRegistry
import hulk.config.HulkConfig
import hulk.filtering... |
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 coursier.launcher
import java.io.File
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path, Paths}
import coursier.launcher.internal.FileUtil
object NativeImageGenerator extends Generator[Parameters.NativeImage] {
// TODO Get some kind of CommandRunner via the params?
// That would... |
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 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 mimir.statistics.facet
import play.api.libs.json._
import mimir.Database
import mimir.algebra._
trait Facet
{
def description: String
def test(db:Database, query:Operator): Seq[String]
def toJson: JsValue
override def toString = description
}
trait AppliesToColumn
extends Facet
{
def facetInvali... |
Explain and rewrite the following Scala code: | package cephui.lib
import scala.concurrent.{Future,Promise}
import org.scalajs.dom
import scala.util.Try
import scala.scalajs.js
object Http {
sealed class HttpFailure(msg: String) extends Exception(msg)
case class RequestFailure(req: dom.XMLHttpRequest) extends HttpFailure(
s"response ${req.status} received;... |
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.util
import com.twitter.concurrent.{Offer, Scheduler, Tx}
import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger, AtomicReference, AtomicReferenceArray}
import java.util.concurrent.{CancellationException, TimeUnit, Future => JavaFuture}
import java.util.{List => JList, Map => JMap}
import... |
Explain and rewrite the following Scala code: | package io.gatling.tcp
import akka.actor.{ActorRef, Props}
import io.gatling.core.akka.BaseActor
import io.gatling.core.check.CheckResult
import io.gatling.core.result.message.{KO, OK, Status}
import io.gatling.core.result.writer.DataWriterClient
import io.gatling.core.session.Session
import io.gatling.core.util.TimeH... |
Explain and rewrite the following Scala code: | package edu.neu.coe.scala.numerics
/**
* This abstract class is the base class for various functions used by LazyNumber algebra.
* It's not that the functions are lazy, it's that they are used by the LazyNumber module.
*
* @author scalaprof
*/
abstract class LazyFunction[X: Numeric] extends Function1[X,X] { ... |
Explain and rewrite the following Scala code: | package com.github.yubessy.urule
import com.netaporter.uri.Uri
class Rule(
matcher: Matcher,
extractor: Extractor,
children: Seq[Rule]
) {
def applyTo(uri: String): Option[Result] =
applyTo(Uri.parse(uri), None).flatMap(x => if (x.isEmpty) None else Some(x))
private def applyTo(uri: Uri, parent: Option... |
Explain and rewrite the following Scala code: | package org.kanyec.ast
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes._
import org.kanyec.SymbolTable
case class MethodNode(methodName: String, arguments: List[VariableNode], returnsValue: Boolean, statements: List[StatementNode]) extends AbstractMethodNode {
def generate(mv: MethodVisitor... |
Explain and rewrite the following Scala code: | /** Copyright 2016 - 2021 Martin Mauch (@nightscape)
*
* 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: | package com.websudos.phantom.builder.query.db.specialized
import java.nio.ByteBuffer
import java.util.UUID
import com.websudos.phantom.tables.{ByteBufferTable, BufferRecord}
import com.websudos.phantom.dsl._
import com.websudos.phantom.testkit._
import com.websudos.util.testing._
class ByteBufferColumnTest extends P... |
Explain and rewrite the following Scala code: | package com.github.jeroenr.tepkin.protocol.command
import com.github.jeroenr.bson.BsonDsl._
import com.github.jeroenr.bson.{BsonDocument}
case class Validate(databaseName: String,
collectionName: String,
full: Option[Boolean] = None,
scandata: Option[Boolean... |
Explain and rewrite the following Scala code: | package com.github.mdr.mash.ns.core
import com.github.mdr.mash.classes.MashClass
/**
* A units type: number of bytes
*/
object BytesClass extends MashClass("core.Bytes") {
override def summaryOpt = Some("Tag class representing a quantity of bytes")
override def parentOpt = Some(AnyClass)
}
|
Explain and rewrite the following Scala code: | package dsmoq.maintenance.services
import scala.util.Failure
import scala.util.Success
import scala.util.Try
import org.joda.time.DateTime
import org.slf4j.MarkerFactory
import com.typesafe.scalalogging.LazyLogging
import dsmoq.maintenance.AppConfig
import dsmoq.maintenance.data.SearchResult
import dsmoq.maintenanc... |
Explain and rewrite the following Scala code: | package de.htw.pgerhard.domain.users
import akka.actor.{ActorLogging, ActorRef, Props}
import akka.util.Timeout
import de.htw.pgerhard.domain.generic.{Envelope, Repository, RepositoryConnector}
import de.htw.pgerhard.domain.users.commands._
import scala.concurrent.{ExecutionContext, Future}
class UserRepository(
... |
Explain and rewrite the following Scala code: | import play.sbt.PlayImport.{cache, filters}
import sbt.Keys._
import sbt._
object Dependencies {
private val sunriseThemeVersion = "0.72.0"
val sunriseEmailVersion = "0.3.0"
private val jvmSdkVersion = "1.37.0"
private val jacksonVersion = "2.7.5"
lazy val jvmSdk = Seq (
libraryDependencies ++= Seq (
... |
Explain and rewrite the following Scala code: | package quotidian
import java.util.Properties
import quotidian.model.{Quote,Search}
import quotidian.web.controller.{QuoteController,SearchController}
object Config {
private[this] val properties = new Properties()
properties.load(getClass().getClassLoader().getResourceAsStream("config.properties"))
val Labels = M... |
Explain and rewrite the following Scala code: | package de.fosd.typechef.featureexpr
/**
* FeatureExprTree is the root class for non-propositional nodes in feature
* expressions, i.e., Integer and If nodes, which cannot be checked for satisfiability.
*/
sealed trait FeatureExprTree[T] {
def asObject(): FeatureExprTree[Object] = this.asInstanceOf[FeatureExprT... |
Explain and rewrite the following Scala code: | package quizleague.web.site.results
import scala.scalajs.js.annotation.JSExport
trait TableUtils {
@JSExport
def nameClass(score1:Int, score2:Int) = if(score1 > score2) "winner" else ""
} |
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: | /*
* Copyright 2016 Renaud Bruneliere
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agree... |
Explain and rewrite the following Scala code: | import sbt._
import Keys._
import play.Play.autoImport._
import PlayKeys._
object ApplicationBuild extends Build {
val appName = "play2-crud-intermediate-controller"
val appVersion = "0.7.4-SNAPSHOT"
val appScalaVersion = "2.11.1"
val appDependencies = Seq(
javaCore, ... |
Explain and rewrite the following Scala code: | package org.reactivecouchbase
import scala.concurrent._
import play.api.libs.iteratee._
import play.api.libs.json._
import com.ning.http.client.{Response, AsyncCompletionHandler}
import org.reactivecouchbase.client.ReactiveCouchbaseException
/**
* Container to run N1QL query against a Couchbase Server. Uses it's own... |
Explain and rewrite the following Scala code: | package com.thesamet.pb
import scala.annotation.StaticAnnotation
import scala.annotation.meta.{beanGetter, beanSetter, field, getter, setter}
class CustomAnnotation() extends StaticAnnotation
class CustomAnnotation1() extends StaticAnnotation
class CustomAnnotation2() extends StaticAnnotation
@getter @setter @bean... |
Explain and rewrite the following Scala code: | /**
* == Labeled Records for Scala ==
*
* If you just want to create a record and play around with it, you
* can use [[Rec.applyDynamic]] or [[Rec.applyDynamicNamed]]:
*
* {{{
* val data0 = Rec("name" -> "Tom", age -> 5)
* val data1 = Rec(name = "Tom", age = 5)
* }}}
*
* You can then access its fields as if ... |
Explain and rewrite the following Scala code: | package exam.national_center_test.xml.choice
/**
* <pre>
* Created on 5/25/15.
* </pre>
*
* @author K.Sakamoto
*/
object ChoiceTermCombo {
def apply(choice: collcetion.ChoiceSet): ChoiceTermCombo = {
new ChoiceTermCombo(choice.set.mapValues(ChoiceTerm(_)))
}
}
/**
* @author K.Sakamoto
* @param choic... |
Explain and rewrite the following Scala code: | package lila.setup
import lila.common.Bus
import lila.common.config.Max
import lila.game.{ GameRepo, IdGenerator, Pov }
import lila.lobby.actorApi.{ AddHook, AddSeek }
import lila.lobby.Seek
import lila.user.{ User, UserContext }
final private[setup] class Processor(
gameCache: lila.game.Cached,
gameRepo: Gam... |
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.invisibletech.myfpscala
object fib {
def fibonacci(n : Int) : Long = {
def aux(n : Int) : Long = {
if (n == 0) 0
else if (n == 1) 1
else aux(n-1) + aux(n-2)
}
aux(n)
}
def fibonaccit(n : Int) : Long = {
@annotation.tailrec
def aux(n : Int, f0 : Int, f1 : Int) :... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2018. Fengguo Wei and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0
* which accompanies this distribution, and is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Detailed contributors ar... |
Explain and rewrite the following Scala code: | package com.knoldus.fh.datastructures
sealed trait List[+A] // `List` data type, parameterized on a type, `A`
case object Nil extends List[Nothing] // A `List` data constructor representing the empty list
case class Cons[+A](head: A, tail: List[A]) extends List[A] // Another data constructor, representing nonempty lis... |
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: | /**
* Copyright (c) 2002-2012 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j 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 Foundati... |
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: | // Copyright 2016 Yahoo Inc.
// Licensed under the terms of the Apache 2.0 license.
// Please see LICENSE file in the project root for terms.
package com.yahoo.ml.caffe
import java.io.File
import com.yahoo.ml.caffe.tools.Binary2Sequence
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.Path
impor... |
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 model.components
import java.io.File
import au.id.cxd.math.count.CrossTabulate
import au.id.cxd.math.data.MatrixReader
import au.id.cxd.math.function.transform.StandardisedNormalisation
import au.id.cxd.math.model.components.QuadraticDiscriminant
import breeze.linalg.DenseMatrix
import inference.TestManovaDat... |
Explain and rewrite the following Scala code: | import _root_.com.olegych.scastie.api.runtime._
class Playground extends _root_.com.olegych.scastie.api.runtime.DomHook { private val instrumentationMap$ = _root_.scala.collection.mutable.Map.empty[_root_.com.olegych.scastie.api.Position, _root_.com.olegych.scastie.api.Render];def instrumentations$ = instrumentationMap... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2011, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, me... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2002-2018 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j 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 Foundatio... |
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: | // Copyright 2016 Carl Pulley
package cakesolutions.docker.testkit.examples
import akka.actor.ActorSystem
import akka.http.scaladsl.model.{HttpEntity, HttpHeader, Multipart, StatusCodes}
import akka.http.scaladsl.testkit.{RouteTestTimeout, ScalatestRouteTest}
import cakesolutions.docker.testkit.DockerComposeTestKit.L... |
Explain and rewrite the following Scala code: | trait Foo {
def jump = Foo.x
}
|
Explain and rewrite the following Scala code: | package scoverage
import scala.collection.mutable.ListBuffer
import java.io.File
/**
* @author Stephen Samuel */
case class Coverage()
extends CoverageMetrics
with MethodBuilders
with java.io.Serializable
with ClassBuilders
with PackageBuilders
with FileBuilders {
val statements = new ListBuffer[Measu... |
Explain and rewrite the following Scala code: | package controllers.quiz.graphmatch
import models.support.UserId
import models.user.User
import org.joda.time.DateTime
import org.junit.runner._
import org.specs2.mutable._
import org.specs2.runner._
@RunWith(classOf[JUnitRunner])
class GraphMatchQuestionFormSpec extends Specification {
val user = User(UserId(0),... |
Explain and rewrite the following Scala code: | package japgolly.scalajs.react.extra.router
sealed trait RouteCmd[+P, A]
object RouteCmd {
/**
* Pushes the given data onto the session history stack with the specified title and, if provided, URL.
*/
case class PushState[P](url: AbsUrl) extends RouteCmd[P, Unit]
/**
* Updates the most recent entry o... |
Explain and rewrite the following Scala code: | // Some iterator grouped/sliding unit tests
object Test {
def it = (1 to 10).iterator
def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]): Unit = {
val xs = it.toList
def fail(msg: String) = "assertion failed on %s: %s".format(xs, msg)
assert(xs.size == expectedLength, fai... |
Explain and rewrite the following Scala code: | package ru.retailrocket.spark.multitool
object HashFNV {
val FNV_32_INIT: Int = 33554467
val FNV_32_PRIME: Int = 0x01000193
def hash(s: String, init: Int=FNV_32_INIT): Int = {
var hval = init
val bytes = s.getBytes
for(i <- bytes) {
hval *= FNV_32_PRIME
hval ^= i
}
hval
}
}
|
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.http4s
package client
import fs2.Task
import org.log4s.getLogger
trait Connection {
private[this] val logger = getLogger
def runRequest(req: Request): Task[Response]
/** Determine if the connection is closed and resources have been freed */
def isClosed: Boolean
/** Determine if the connectio... |
Explain and rewrite the following Scala code: | package tshrdlu.twitter
/**
* Copyright 2013 Jason Baldridge
*
* 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 require... |
Explain and rewrite the following Scala code: | /**
* Copyright 2014 Kosta Korenkov
* Copyright 2014 Kangmo Kim
*
* 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 require... |
Explain and rewrite the following Scala code: | package edu.colorado.hopper.synthesis
import com.ibm.wala.classLoader.IMethod
import com.ibm.wala.ipa.cha.IClassHierarchy
import com.ibm.wala.types.MethodReference
import edu.colorado.hopper.state.InstanceFld
import edu.colorado.walautil.ClassUtil
object InterfaceMethodField {
def makeInterfaceMethodField(m : Meth... |
Explain and rewrite the following Scala code: | /* clojy
*
* From Clojure to Python and back
*
* Copyright (C) 2015 Stefan Zimmermann <zimmermann.code@gmail.com>
*
* clojy 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 th... |
Explain and rewrite the following Scala code: | package io.cumulus.models.fs
import scala.collection.immutable
import enumeratum.{Enum, EnumEntry, PlayJsonEnum}
import io.cumulus.persistence.anorm.AnormEnum
import play.api.mvc.QueryStringBindable
sealed abstract class FsNodeType extends EnumEntry
object FsNodeType extends Enum[FsNodeType] with PlayJsonEnum[FsNod... |
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.github.fntzr.spray.routing.ext.test.specifysubroute
import org.scalatest._
import spray.http.{FormData}
import spray.testkit.ScalatestRouteTest
import spray.routing._
import com.github.fntzr.spray.routing.ext._
case class Model0(title: String)
case class Model1(title: String)
case class Model2(title: Strin... |
Explain and rewrite the following Scala code: | package calc
/**
* Last night I went with my wife to a party where four other married couples were present.
*
* Every person shook hands with only the people he or she was NOT acquainted with.
* (Obviously, no one shook his or her own hand or spouse's hand, and no one shook hands with the same person twice.)
... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 The BigDL 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 agr... |
Explain and rewrite the following Scala code: | package org.scaladebugger.api.profiles.java.requests.breakpoints
import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger}
import org.scaladebugger.api.profiles.java.JavaDebugProfile
import org.scaladebugger.api.utils.JDITools
import org.scaladebugger.api.virtualmachines.DummyScalaVirtualMachine
import org.sc... |
Explain and rewrite the following Scala code: | package com.twitter.io
import java.io.File
import org.junit.runner.RunWith
import org.scalatest.WordSpec
import org.scalatest.junit.JUnitRunner
import com.twitter.util.TempFolder
@RunWith(classOf[JUnitRunner])
class FilesTest extends WordSpec with TempFolder {
"Files" should {
"delete" in withTempFolder {
... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2013 original 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 a... |
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: | package test
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
/**
* Add your spec here.
* You can mock out a whole application including requests, plugins etc.
* For more information, consult the wiki.
*/
class ApplicationSpec extends Specification {
"Application" should {
... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.lang
import com.intellij.psi.{PsiElement, PsiFile}
import org.jetbrains.plugins.scala.extensions._
import org.jetbrains.plugins.scala.lang.psi.api.base.types.ScRefinement
import scala.meta.internal.semanticdb
package object resolveSemanticDb {
implicit class RangeOps(private va... |
Explain and rewrite the following Scala code: | package zamblauskas
package object functional
extends ToApplicativeOps
with ToFunctorOps
with ToSemigroupOps
with ToAlternativeOps
|
Explain and rewrite the following Scala code: | package slick.jdbc.meta
import java.sql._
import slick.jdbc.{ResultSetAction, JdbcTypesComponent}
/** A wrapper for a row in the ResultSet returned by DatabaseMetaData.getColumns(). */
case class MColumn(
table: MQName, name: String, sqlType: Int, typeName: String,
size: Option[Int], decimalDigits: Option[Int], ... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2013 Alcatel-Lucent.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* Licensed 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 cop... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017. Yuriy Stul
*/
package com.stulsoft.poc.xml
/** Playing with standard Scala XML
*
* @author Yuriy Stul
*/
object Test1 extends App {
test1()
test2()
def test1(): Unit = {
println("==>test1")
val books = <books>
<book id="b1615">Don Quixote</book>
<book id="b1... |
Explain and rewrite the following Scala code: | package be.wegenenverkeer.atomium.play
import be.wegenenverkeer.atomium.api.Codec
import play.api.libs.json.{Format, Json}
/**
* Codec for encoding Entries using Play Json
* @param entryFormat the Format for the Entry
* @tparam E The type of the Entry
*/
case class PlayJsonEntryCodec[E](implicit val entryForm... |
Explain and rewrite the following Scala code: | package logic {
object S99Logic {
def cross(xs: List[String], ys: List[String]):List[String] = for { x <- xs; y <- ys } yield x ++ y
def gray(codeLength: Integer): List[String] = {
val binaryStr = List("0", "1")
var grayCode = binaryStr
for (numRepeat <- 2 to codeLength) {
grayCode... |
Explain and rewrite the following Scala code: | // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package com.microsoft.spark.csharp
import org.apache.spark.SparkContext
import org.apache.spark.sql.SQLContext
import org.apache.spark.streaming.Duration
/**
* Perf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.