instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package com.lucidchart.open.nark.models
import com.lucidchart.open.nark.models.records.Target
import com.lucidchart.open.nark.models.records.TargetSummarizer
import anorm.SqlParser._
import java.util.UUID
import anorm._
import play.api.db.DB
import play.api.Play.current
import AnormImplicits._
class TargetModel exten... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 Dmytro Rashko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed t... |
Explain and rewrite the following Scala code: | package utils
sealed trait Nucleotide
sealed trait DnaNucleotide extends Nucleotide
sealed trait RnaNucleotide extends Nucleotide
case object Adenine extends DnaNucleotide with RnaNucleotide
case object Cytosine extends DnaNucleotide with RnaNucleotide
case object Guanine extends DnaNucleotide with RnaNucleotide
case... |
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: | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 Lars Kroll <bathtor@googlemail.com>
*
* 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 limitatio... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2018 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package reactor.core.scala.publisher
trait ExitCondition
case object Completed extends ExitCondition
case object Cancelled extends ExitCondition
case class Error(ex: Throwable) extends ExitCondition
|
Explain and rewrite the following Scala code: | package skinny
import org.scalatest._
class ParamTypeSpec extends FlatSpec with Matchers {
behavior of "ParamType.Boolean"
it should "convert raw value to expected type" in {
ParamType.Boolean.unapply("true") should equal(Some(true))
ParamType.Boolean.unapply("false") should equal(Some(false))
Param... |
Explain and rewrite the following Scala code: | package d_m
import scala.tools.nsc._
/** Taken from ScalaJS, copyright Sébastien Doeraene
*
* Original at
* https://github.com/scala-js/scala-js/blob/950fcda1e480d54b50e75f4cce5bd4135cb58a53/compiler/src/main/scala/org/scalajs/nscplugin/CompatComponent.scala
*
* Modified with only superficial understanding of t... |
Explain and rewrite the following Scala code: | package uk.gov.gds.ier.transaction.overseas.confirmation.blocks
import uk.gov.gds.ier.model.WaysToVoteType._
import uk.gov.gds.ier.model.WaysToVoteType
trait WaysToVoteBlocks {
self: ConfirmationBlock =>
def waysToVote = {
val way = form(keys.waysToVote.wayType).value.map(WaysToVoteType.parse(_))
val... |
Explain and rewrite the following Scala code: | package ohnosequences.obesnp
/**
* Created by evdokim on 29/10/2015.
*/
trait ChromosomeNaming {
def decode(name: String): String
def encode(name: String): String
}
object OneThousandGenomes extends ChromosomeNaming {
override def decode(name: String): String = {
"chr" + name
}
override def encode(n... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2013 Artima, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agre... |
Explain and rewrite the following Scala code: | package org.tejo.iza.rules.facts
import pl.pej.trelloilaro.api.model.BoardJson
import scala.beans.BeanInfo
@BeanInfo
case class BoardFact(boardId: String)
object BoardFact {
def apply(json: BoardJson): BoardFact = {
BoardFact(json.id)
}
}
|
Explain and rewrite the following Scala code: | runCont(ka) { a =>
val kb = kab(a)
runCont(kb)(hb)
} |
Explain and rewrite the following Scala code: | package edu.gemini.shared
import java.awt.Toolkit
import java.awt.event.InputEvent
import java.net.URL
import java.util.logging.Logger
import javax.swing.{InputMap, JTextArea, JTextField, KeyStroke}
object Platform extends Enumeration {
val Mac, Windows, Other = Value
private val LOGGER = Logger.getLogger(getCl... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.performance
import java.io.File
import java.util
import com.intellij.openapi.externalSystem.model.ProjectSystemId
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings
import com.intellij.openapi.externalSystem.test.ExternalSystemImportingTestCase
import com.i... |
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: | /**
* Copyright (C) 2015 Orbeon, Inc.
*
* 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
* 2.1 of the License, or (at your option) any later version.
*
* This program i... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2020 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.data
import play.api.data.format._
object JodaForms {
import JodaFormats._
/**
* Constructs a simple mapping for a date field (mapped as `org.joda.time.DateTime type`).
*
* For example:
* {{{
* Form("b... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2015-2016 Philipp Haller
*/
package lacasa.samples.words
import lacasa.{Box, CanAccess, Actor, ActorRef, LaCasaApp, LaCasa, doNothing}
import Box._ // import `mkBox`
class Words {
var list: List[String] = List()
}
class ActorA extends Actor[Words] {
override def receive(box: Box[Words])
... |
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 2014 Treode, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... |
Explain and rewrite the following Scala code: | /**
* @author Petri Kivikangas
* @date 28.4.2012
*
*/
package cdl.javacompat
import scala.collection.JavaConversions
object CDLConversions {
def toList[T](coll: java.util.List[T]): List[T] = JavaConversions.asScalaBuffer(coll).toList
} |
Explain and rewrite the following Scala code: | package org.a4r
import org.a4r.factory.ProviderFactory
import net.ceedubs.ficus.Ficus._
/**
* Created by brendan on 6/4/17.
*/
object ClientMain extends A4RApp with A4RActorSystem with A4RPubSub {
override def main(args: Array[String]): Unit = {
info(s"starting with $args")
super.main(args)
val... |
Explain and rewrite the following Scala code: | package jellies.client
import GraphicsUtils._
import jellies.layout.ModelView
import jellies.layout.Layout
import jellies.game.JellyColour
import jellies.game.MergeableColour
import jellies.game.Model
import jellies.layout.SameInfo
import jellies.game.Perspective
import jellies.game.Location
import jellies.layout.Layo... |
Explain and rewrite the following Scala code: | package me.ivanyu.luscinia
import akka.actor.ActorSystem
import akka.testkit.{TestProbe, TestFSMRef, ImplicitSender, TestKit}
import me.ivanyu.luscinia.entities._
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, Matchers}
abstract class TestBase extends TestKit(ActorSystem("Test"))
with FunSuiteLike
// w... |
Explain and rewrite the following Scala code: | /**
* Created by apanchul on 6/9/16.
*/
import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue
import java.util.UUID
import scala.actors._
import scala.actors.Actor._
import scala.collection.mutable.Queue
object UniqueIdGenerator{
val uuids = new Queue[UUID] //new LinkedBloc... |
Explain and rewrite the following Scala code: | /**
* BubbleSortSpec.scala --- Properties-based testing of bubble sort
*
* Copyright (C) 2014 Aaron S. Hawley
*
* This program 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 Foundation, either version 3 of the Lic... |
Explain and rewrite the following Scala code: | package dbx.api
import dbx.transaction.TransactionDefinition
/**
* Created by sauntor on 17-3-21.
*/
object Isolation extends Enumeration {
type Isolation = Value
/**
* Support a current transaction, create a new one if none exists.
* Analogous to EJB transaction attribute of the same name.
* <p... |
Explain and rewrite the following Scala code: | import scala.annotation.tailrec
import scala.collection.SortedSet
package object elasticTabstops:
// convenience functions to wrap Java's unintuitive split method
def split(string: String, char: Char) = string.split(char.toString, -1) // -1 so we get trailing empty strings
def splitAndStrip(string: String, cha... |
Explain and rewrite the following Scala code: | // Copyright 2012 Foursquare Labs Inc. All Rights Reserved.
// Copyright 2015 Sgrouples Inc. All Rights Reserved.
import sbt._
import Keys.{scalaVersion, _}
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixScalaBinaryVersion, scalafixSemanticdb}
object RogueSettings {
val nexus = "https://nexus.groupl.es/"
... |
Explain and rewrite the following Scala code: | package is.hail.asm4s.joinpoint
// uninhabitable dummy type, indicating some sort of control flow rather than returning a value;
// used as the return type of JoinPoints
case class Ctrl(n: Nothing)
|
Explain and rewrite the following Scala code: | package troy
package cql.ast.dml
import troy.cql.ast.BindMarker
sealed trait UpdateParam
final case class Timestamp(value: UpdateParamValue) extends UpdateParam
final case class Ttl(value: UpdateParamValue) extends UpdateParam
sealed trait UpdateParamValue
final case class UpdateValue(value: String) extends UpdatePa... |
Explain and rewrite the following Scala code: | package org.http4s
package parser
import cats.data.NonEmptyList
import org.http4s.headers.Authorization
class AuthorizationHeaderSpec extends Http4sSpec {
def hparse(value: String) = HttpHeaderParser.AUTHORIZATION(value)
"Authorization header" should {
"Parse a valid OAuth2 header" in {
val token = ((... |
Explain and rewrite the following Scala code: | package com.softwaremill.bootzooka.email.application
import com.softwaremill.bootzooka.email.application.SmtpEmailSender.EmailDescription
import com.softwaremill.bootzooka.email.domain.EmailContentWithSubject
import com.typesafe.scalalogging.StrictLogging
import scala.collection.mutable.ListBuffer
import scala.concur... |
Explain and rewrite the following Scala code: | package uk.co.odinconsultants.bitcoin.apps
import org.apache.spark.{SparkConf, SparkContext}
trait SparkClient {
def sparkContext: SparkContext = {
val sparkConfig = new SparkConf()
sparkConfig.setAppName(this.getClass.getSimpleName)
new SparkContext(sparkConfig)
}
}
|
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.annotator.gutter
/**
* Pavel.Fatin, 21.01.2010
*/
class GroupLineTest extends LineMarkerTestBase {
protected override def getBasePath = super.getBasePath + "/group/line/"
def testAnonymousClasses() = doTest()
def testBlocks() = doTest()
def testClasses() = doTest()
def... |
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.linker.frontend.optimizer
... |
Explain and rewrite the following Scala code: | package com.socrata.bq.soql
import com.socrata.soql.typed._
import com.socrata.soql.types._
import com.socrata.datacoordinator.id.UserColumnId
import Sqlizer._
import SqlizerContext._
class StringLiteralSqlizer(lit: StringLiteral[SoQLType]) extends Sqlizer[StringLiteral[SoQLType]] {
val underlying = lit
@Overri... |
Explain and rewrite the following Scala code: | package pw.ian.sysadmincraft.world
import java.util.Random
import org.bukkit.{WorldCreator, Material, World}
import org.bukkit.generator.ChunkGenerator
import org.bukkit.generator.ChunkGenerator.BiomeGrid
class PillarWorldGenerator extends ChunkGenerator {
override def generateBlockSections(world: World, random: ... |
Explain and rewrite the following Scala code: | package com.redis.operations
import com.redis.Connection
/**
* Redis sort operations
*
*/
trait SortOperations{
def getConnection(key: String): Connection
// SORT
// Sort a Set or a List accordingly to the specified parameters.
def sort(args: Any): Option[List[Option[String]]] = args match {
cas... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.lang.scaladoc.psi.api
import _root_.org.jetbrains.plugins.scala.lang.psi.ScalaPsiElement
/**
* User: Alexander Podkhalyuzin
* Date: 22.07.2008
*/
trait ScDocParamRef extends ScalaPsiElement {
} |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com>
*/
package play.it.http
import play.api.inject.guice.GuiceApplicationBuilder
import scala.concurrent.duration._
import play.api.mvc._
import play.api.test._
import play.api.libs.ws._
import play.it._
class NettyFormFieldOrderSpec extends Form... |
Explain and rewrite the following Scala code: | package debop4s.data.orm.mapping.associations
import java.lang.{Long => jLong}
import java.util
import javax.persistence._
import debop4s.core.utils.Hashs
import debop4s.data.orm.AbstractJpaJUnitSuite
import debop4s.data.orm.model.HibernateEntityBase
import org.hibernate.{annotations => hba}
import org.junit.Test
im... |
Explain and rewrite the following Scala code: | //
// Substitution.scala -- Scala trait Substitution
// Project OrcScala
//
// Created by dkitchin on Jul 13, 2010.
//
// Copyright (c) 2017 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's to... |
Explain and rewrite the following Scala code: | package lila.gameSearch
private[gameSearch] object Fields {
val status = "s"
val turns = "t"
val rated = "r"
val perf = "p"
val uids = "u"
val winner = "w"
val winnerColor = "c"
val averageRating = "a"
val ai = "i"
val date = "d"
val duration = "l"
val clockInit = "ct"
val clockInc = "ci"
... |
Explain and rewrite the following Scala code: | /**
* Swaggy Jenkins
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.1.2-pre.0
* Contact: blah@cliffano.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not ed... |
Explain and rewrite the following Scala code: | package controllers.preview
import org.specs2.mutable._
import utils.{WithJsBrowser, WithBrowser}
import utils.pageobjects.preview.PreviewPage
import utils.pageobjects.your_income.{GRentalIncomePage, GYourIncomePage}
import utils.pageobjects.{TestData, PageObjects}
class PreviewPageYourIncomeRentalIncomeSpec extends ... |
Explain and rewrite the following Scala code: | package geek.lawsof.physics.lib.util.handler
import cpw.mods.fml.common.IFuelHandler
import cpw.mods.fml.common.registry.GameRegistry
import net.minecraft.item.ItemStack
/**
* Created by anshuman on 28-05-2014.
*/
object FuelHandler extends IFuelHandler {
GameRegistry.registerFuelHandler(this)
var fuels: Map[I... |
Explain and rewrite the following Scala code: | package org.scalafmt.cli
/**
* This code is copy/pasted from (Apache 2 licence)
* https://github.com/alexarchambault/coursier/blob/51fefe5c29d95752ce487f60d333b1f8a91dd1b0/cache/src/main/scala/coursier/TermDisplay.scala
*
* which in turn was copy/pasted from (MIT licence)
* https://github.com/lihaoyi/Ammonit... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package io.fintrospect.formats
import com.twitter.finagle.http.Status
import com.twitter.io.{Buf, Bufs}
import org.scalatest.{FunSpec, Matchers}
abstract class ResponseBuilderSpec[T](bldr: AbstractResponseBuilder[T]) extends FunSpec with Matchers {
val message = "some text goes here"
val customType: T
val cus... |
Explain and rewrite the following Scala code: | package paint
import scala.scalajs.js.annotation.JSExport
import org.scalajs.dom
import org.scalajs.dom._
import org.scalajs.dom.ext.KeyCode
import paint.canvas.CanvasCoRoutine
import paint.coroutine.CoRoutine
import paint.geometry.Geometry.{DoublePoint, PlaneTransformation, Point}
import paint.portfolio.CoRoutinePort... |
Explain and rewrite the following Scala code: | package scala.scalanative
package nir
package serialization
import java.nio.ByteBuffer
import scala.collection.mutable
import nir.{Tags => T}
final class BinarySerializer(buffer: ByteBuffer) {
import buffer._
final def serialize(defns: Seq[Defn]): Unit = {
val names = defns.map(_.name)
val positions ... |
Explain and rewrite the following Scala code: | package com.socrata.bq.soql
import com.socrata.datacoordinator.id.UserColumnId
import com.socrata.soql.SoQLAnalysis
import com.socrata.soql.types._
import com.socrata.soql.typed.{OrderBy, CoreExpr}
/**
* Converts SoQLAnalysis and a table name into a complete BigQuery SQL.
* @param analysis The analysis containing i... |
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: | package pl.newicom.dddd.delivery
import akka.actor.ActorPath
import akka.persistence.AtLeastOnceDelivery.AtLeastOnceDeliverySnapshot
import akka.persistence._
import pl.newicom.dddd.delivery.protocol.alod.Delivered
import pl.newicom.dddd.messaging.{AddressableMessage, Message}
import pl.newicom.dddd.persistence.{Persi... |
Explain and rewrite the following Scala code: | package com.misiunas.geoscala.transformations
import com.misiunas.geoscala.Point
/**
* User: karolis@misiunas.com
* Date: 11/08/2013
* Time: 19:24
*/
trait Translations[T <: Translations[T]] extends LinearTransformations[T] {
this: T =>
/** will move a geometrical object alon the cartesian coordinates */
d... |
Explain and rewrite the following Scala code: | package com.stulsoft.ysps.pfuture
import com.typesafe.scalalogging.LazyLogging
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.util.{Failure, Success}
/**
* Created by Yuriy Stul on 10/27/2016.
*
* See original co... |
Explain and rewrite the following Scala code: | package unicredit.example
import org.apache.hadoop.fs.Path
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}
import unicredit.spark.hbase._
/**
* Example: bulk load to hbase of a tab separated file
*/
object WriteTsvToHFiles extends App {
case class Config(quorum: String = "localh... |
Explain and rewrite the following Scala code: | package grouproulette
import scala.util.Random
import scala.math.{ log, floor }
object GroupRoulette {
val trials = 1000
val rng = new Random()
def main(args: Array[String]) = {
for (n <- 1 to 1000) {
val e = runTrials(n)
val f = log(n) - floor(log(n))
println(s"$e $f")
}
}
def ... |
Explain and rewrite the following Scala code: | package eventstore
package core
package operations
import OperationError._
import Inspection.Decision._
private[eventstore] final case class TransactionCommitInspection(out: TransactionCommit)
extends ErrorInspection[TransactionCommitCompleted, OperationError] {
def transactionId = out.transactionId
def dec... |
Explain and rewrite the following Scala code: | package com.twitter.zipkin.storage.hbase.utils
import org.specs.SpecificationWithJUnit
import java.util.concurrent.atomic.AtomicLong
import com.twitter.zipkin.storage.util.Retry
class RetrySpec extends SpecificationWithJUnit {
"Retry" should {
"return if success" in {
val counter = new AtomicLong(0)
... |
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 frameless
import org.scalacheck.Prop
import org.scalacheck.Prop.{forAll, _}
class QueryExecutionTests extends TypedDatasetSuite {
test("queryExecution") {
def prop[A: TypedEncoder](data: Vector[A]): Prop = {
val dataset = TypedDataset.create[A](data)
dataset.queryExecution =? dataset.datase... |
Explain and rewrite the following Scala code: | package util
import org.opalj.tac._
import org.opalj.br.Method
import taintanalysis.{MStmt, Context}
object Util {
def containsInvokeExpr(s: Stmt): Boolean = {
???
}
def getInvokeExpr(s: MStmt): MStmt = {
???
}
def isSink(s: Stmt): Boolean = {
???
}
def getSignature(c: Call): String = {... |
Explain and rewrite the following Scala code: | /*
Deduction Tactics
Copyright (C) 2012-2015 Raymond Dodge
This program 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 Foundation, either version 3 of the License, or
(at your option) any later version.
This progra... |
Explain and rewrite the following Scala code: | package ucesoft.cbm.formats
object MFM {
/**
* MFM Encoding
* Hex 4E written as a gap, with 10 sectors of data, with full gaps written for motor speed variation.
12 Bytes of 00
3 Bytes of Hex A 1 (Data Hex A 1, Clock Hex OA)
1 Byte of FE (ID Address Mark)
1 Byte (Track Number)
1 B... |
Explain and rewrite the following Scala code: | class SCL5472A {
class C
class A
class B extends A
class D extends B
def foo(z: C {type T <: B}) = 1
def foo(z: Any) = "text"
/*start*/(foo(new C {type T = A}), foo(new C {type T = D}))/*end*/
}
//(String, Int) |
Explain and rewrite the following Scala code: | package org.tinydvr.schedulesdirect.api
import org.joda.time.{LocalDate, DateTime}
//
// Json types handled by the api
//
case class GetClientResponse(response: String,
code: Int,
client: String,
version: 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: | // Solution-1.scala
// Solution to Exercise 1 in "Pattern Matching"
import com.atomicscala.AtomicTest._
def matchColor(color:String):String = {
if(color == "red") "RED"
else if(color == "blue") "BLUE"
else if(color == "green") "GREEN"
else "UNKNOWN COLOR: " + color
}
matchColor("white") is "UNKNOWN COLOR: whi... |
Explain and rewrite the following Scala code: | // https://github.com/functional-streams-for-scala/fs2/blob/3522315043ce31beb121c44cec4a7b1ce4e509e3/docs/src/ReadmeExample.md
package com.rossabaker
package benchmarks
import org.openjdk.jmh.annotations._
@State(Scope.Thread)
@Fork(2)
@Measurement(iterations = 10)
@Warmup(iterations = 10)
@Threads(1)
class Fahrenhei... |
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 ohnosequences.scarph.test.titan
import GodsSchema._
object GodsImplementation {
/*
### Vertices
*/
case object titan extends TVertex(Titan)
case object god extends TVertex(God)
case object demigod extends TVertex(Demigod)
case object human extends TVertex(Human)
case object mons... |
Explain and rewrite the following Scala code: | package info.hupel.isabelle.japi
import java.io.FileNotFoundException
import java.nio.file.Path
import java.util.{List => JList}
import scala.collection.JavaConverters._
import info.hupel.isabelle.api._
import info.hupel.isabelle.setup._
object JResources {
def dumpIsabelleResources(): JResources =
Resources... |
Explain and rewrite the following Scala code: | package edu.vanderbilt.accre
import org.htmlcleaner.{HtmlCleaner, HtmlNode, TagNode, TagNodeVisitor}
import org.apache.commons.lang.StringEscapeUtils.escapeHtml
import scala.util.Try
/**
* Created by arnold-jr on 12/22/16.
*/
package object stackex {
def getFullText(text: String) = escapeHtml(text)
def get... |
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 funpep
package util
import java.util.UUID
import scalaz.syntax.applicative._
import atto._
import atto.parser.all._
import atto.syntax.parser._
private[util] trait Parsers {
def eoi: Parser[Unit] = atto.parser.combinator.endOfInput
def eol: Parser[Unit] = (cr | lf).void | (cr ~ lf).void
def cr: Par... |
Explain and rewrite the following Scala code: | //
// Log2.scala -- Scala object Log2
// Project OrcScala
//
// Copyright (c) 2018 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at
// URL: http://orc.csr... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2020 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package api.entities
/**
* Authenticated client information
*
* @param version client version
*/
case class ClientInformation(version: String)
|
Explain and rewrite the following Scala code: | package com.citypay.pan.search.util
import java.io.{BufferedReader, InputStreamReader}
import java.lang.management.ManagementFactory
import java.nio.ByteBuffer
import com.sun.management.UnixOperatingSystemMXBean
import scala.annotation.tailrec
import scala.util.Try
import Math._
/**
* Util classes used by the sca... |
Explain and rewrite the following Scala code: | // See LICENSE for license details.
package librefpga.test
import Chisel.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}
import librefpga.Interconnect
import chisel3._
import chisel3.util._
import scala.util.Random
class InterconnectUnitTester(c: Interconnect) extends PeekPokeTester(c) {
private val ic = c
... |
Explain and rewrite the following Scala code: | import akka.Message
import scalaz.concurrent.{Actor, Strategy}
import scalaz.concurrent.Actor._
class MyActor {
private var counter = 0
def handler(message: Message): Unit = {
counter += 1
println(s"#$counter: ${message.text}")
}
}
object MyActor {
def create: Actor[Message] = Actor.a... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package config
import com.intellij.openapi.project.Project
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.impl.libraries.{ProjectLibraryTable, ApplicationLibraryTable}
import com.intellij.openapi.roots.libraries.Library.ModifiableModel
import com.intelli... |
Explain and rewrite the following Scala code: | package org.scalatra
package servlet
import javax.servlet.http.HttpSession
/**
* Extension methods to the standard HttpSession.
*/
case class RichSession(session: HttpSession) extends AttributesMap
{
def id = session.getId
protected def attributes = session
}
|
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 2011-2016 GatlingCorp (http://gatling.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by appli... |
Explain and rewrite the following Scala code: | package com.lucidchart.open.nark.models
import anorm._
import anorm.SqlParser._
import AnormImplicits._
import com.lucidchart.open.nark.models.records.{AlertTagSubscription, AlertTagSubscriptionRecord, AlertType, User}
import java.util.UUID
import play.api.Play.current
import play.api.Play.configuration
import play.ap... |
Explain and rewrite the following Scala code: | package com.github.novamage.svalidator.html
import com.github.novamage.svalidator.utils.TypeBasedEnumeration
/** A type based enumeration with values for each possible form element whose attributes can be intercepted by the
* [[com.github.novamage.svalidator.html.HtmlAttributeDecorator HtmlAttributeDecorator]]
*
... |
Explain and rewrite the following Scala code: | /*
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* 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 b... |
Explain and rewrite the following Scala code: | package de.tudarmstadt.lt.flinkdt.tasks
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.scala.DataSet
import org.apache.flink.api.scala._
import scala.reflect.ClassTag
/**
* Created by Steffen Remus
*/
class DSTaskChain[I : ClassTag : TypeInformation, O : ClassTag : TypeIn... |
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 mesosphere.marathon
import akka.Done
import akka.actor._
import akka.event.{EventStream, LoggingReceive}
import akka.pattern.pipe
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import com.typesafe.scalalogging.StrictLogging
import mesosphere.marathon.core.deployment.{DeploymentManag... |
Explain and rewrite the following Scala code: | package alternatives.breeze
import breeze.util.BloomFilter
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
@State(Scope.Benchmark)
class AddLongItemBenchmark {
private val itemsExpected = 1000000L
private val falsePositiveRate = 0.01
private val bf = BloomFilter.optimallySized[Long](itemsExpected... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.stats
import com.twitter.common.metrics.{MetricCollisionException, Metrics}
import com.twitter.util.Time
import com.twitter.util.events
import org.junit.runner.RunWith
import org.scalacheck.{Gen, Arbitrary}
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scal... |
Explain and rewrite the following Scala code: | package au.com.dius.pact.consumer
import org.specs2.mutable.Specification
import au.com.dius.pact.model.MockProviderConfig
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
@RunWith(classOf[JUnitRunner])
class MockProviderConfigSpec extends Specification {
"port server config" should {
"selec... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.