instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package com.horizon.exchangeapi.tables import com.horizon.exchangeapi.ApiTime import slick.jdbc.PostgresProfile.api._ import org.slf4j._ import scala.collection.mutable.ListBuffer /** Stores the current DB schema version, and includes methods to upgrade to the latest schema. */ case class SchemaRow(id: Int, schemaV...
Explain and rewrite the following Scala code:
package com.productfoundry.akka.cqrs import akka.persistence.PersistentActor import com.productfoundry.akka.GracefulPassivation /** * Defines a domain entity. */ trait Entity extends PersistentActor with GracefulPassivation { final val entityName: String = context.parent.path.name final val entityId: String =...
Explain and rewrite the following Scala code:
package skadi.container import scala.collection.mutable import skadi.beans.Bean import skadi.container.processing.BeanProcessor import skadi.container.validation.Error import skadi.container.validation.Validator import skadi.util.Loggable /** * Defines the algorithm and components that are required to initalize and...
Explain and rewrite the following Scala code:
package com.wavesplatform.database import org.iq80.leveldb.{DB, DBIterator, ReadOptions} trait DBResource extends AutoCloseable { def get[V](key: Key[V]): V def get(key: Array[Byte]): Array[Byte] def iterator: DBIterator } object DBResource { def apply(db: DB): DBResource = new DBResource { private[this]...
Explain and rewrite the following Scala code:
package com.codility.github import com.codility.Solution import scala.runtime.ScalaRunTime object PermMissingElem extends Solution[Array[Int], Int]{ /* Task description is from from https://github.com/wilgov22/Codility #CODILITY ## PermMissingElem - Find the missing element in a given permutation. ### Ta...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2016 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 is ...
Explain and rewrite the following Scala code:
package keystoneml.utils import java.io.{FileReader, ByteArrayInputStream} import breeze.linalg.DenseMatrix import breeze.stats.distributions.{Gaussian, RandBasis, ThreadLocalRandomGenerator, Rand} import edu.berkeley.cs.amplab.mlmatrix.RowPartitionedMatrix import org.apache.commons.io.IOUtils import org.apache.common...
Explain and rewrite the following Scala code:
package macroExpand import scala.tools.nsc.Global import scala.tools.nsc.plugins.{Plugin => NscPlugin} class Plugin(val global: Global) extends NscPlugin { import global._ import analyzer._ import scala.reflect.internal.Mode val name = "macroExpand" val description = "A sample analyzer plugin that override...
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.models.request /** * Created by Iliya Tryapitsin on 04.03.14. */ object AdminActionType extends Enumeration { type AdminActionType = Value val RenewDatabase = Value("RENEWDATABASE") val UpdateIssuerSettings = Value("UPDATEISSUERSETTINGS") val UpdateEmailSettings = Value("UPDATEEMAI...
Explain and rewrite the following Scala code:
package mayton.primes import java.util.Random import mayton.primes.PrimeLib._ import mayton.primes.Stohastic._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.must.Matchers class StohasticSpec extends AnyFlatSpec with Matchers { "Формула объединения и пересечения событий A B" must "be cor...
Explain and rewrite the following Scala code:
package org.apache.spark.ml.dsl.utils import scala.runtime.ScalaRunTime /** * Created by peng on 31/05/17. */ trait Verbose extends Product { def shortStr: String = ScalaRunTime._toString(this) def detail: String = "" def withDetail(str: String): String = { val result = str + Option(detail) .fil...
Explain and rewrite the following Scala code:
package rovak.steamkit.steam.language.internal.msg import rovak.steamkit.steam.language.internal.SteamSerializableMessage import rovak.steamkit.steam.language.{EUniverse, EMsg} import rovak.steamkit.util.stream.{BinaryReader, BinaryWriter} object MsgChannelEncryptRequest { val PROTOCOL_VERSION = 1 } class MsgChann...
Explain and rewrite the following Scala code:
package com.ubirch.avatar.core.prometheus import com.ubirch.avatar.config.Config import io.prometheus.client.{Counter, Histogram} class Timer(timerName: String) { private val prefix = Config.enviroment.replace("-", "_").trim private val enabled = Config.prometheusEnabled private var timer : Histogram.Timer =...
Explain and rewrite the following Scala code:
package argonaut import scalaz.{Each => _, Index => _, _}, Scalaz._ import scalaz.syntax.std.option._ /** * A data type representing possible <a href="http://www.json.org/">JSON</a> values. * * @author Tony Morris * @author Dylan Just * @author Mark Hibberd */ sealed trait Json { import Json._ import JsonId...
Explain and rewrite the following Scala code:
import scala.reflect._ @BeanInfo class Bean1 { var name: String = _ val hello: String = "Hello!" def hi = "Hi!" }
Explain and rewrite the following Scala code:
package sri.reactive2015.components import chandu0101.macros.tojs.JSMacro import sri.core.{React, ReactElement, ReactNode} import scala.scalajs.js import sri.mobile.all._ import scala.scalajs.js.Dynamic.{global => g} import scala.scalajs.js.{UndefOr => U, undefined} case class ScrollableTabView(key: U[String] = unde...
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.scaladebugger.language.models /** * Represents the context about the program state at a point in time. * * @param currentScope The local scope of the program at a point in time */ case class Context( currentScope: Scope ) { /** * Retrieves all available variables relative to this context. * ...
Explain and rewrite the following Scala code:
import scala.slick.driver.H2Driver.simple._ // Demonstrates various ways of reading data from an Invoker. object InvokerMethods extends App { // A simple dictionary table with keys and values class Dict(tag: Tag) extends Table[(Int, String)](tag, "INT_DICT") { def key = column[Int]("KEY", O.PrimaryKey) de...
Explain and rewrite the following Scala code:
package com.cloudray.scalapress.plugin.ecommerce.tag import org.scalatest.{OneInstancePerTest, FunSuite} import org.scalatest.mock.MockitoSugar import com.cloudray.scalapress.plugin.ecommerce.domain.Order import javax.servlet.http.HttpServletRequest import com.cloudray.scalapress.plugin.ecommerce.tags.InvoiceAccountEm...
Explain and rewrite the following Scala code:
/* * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
Explain and rewrite the following Scala code:
package flaky import java.io.File import java.text.SimpleDateFormat import java.util.Date import scalatags.Text import scalatags.Text.all.{a, hr, href, p, _} package object web { def footer(): Text.TypedTag[String] = { p( hr(), p( ReportCss.footer, "Created with ", a(href :=...
Explain and rewrite the following Scala code:
package mesosphere.marathon package integration import akka.stream.scaladsl.{ Sink, Source, Tcp } import mesosphere.AkkaIntegrationTest import mesosphere.marathon.integration.setup._ import mesosphere.util.PortAllocator import org.scalatest.concurrent.Eventually @IntegrationTest class MarathonStartupIntegrationTest e...
Explain and rewrite the following Scala code:
package jgo.tools.compiler package scope import interm.symbol._ trait GrowableScope extends Scope { def put(name: String, symbol: Symbol): Boolean }
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 com.github.j5ik2o.forseti.domain.json.jwk import io.circe.{Decoder, Encoder} object PublicKeyUse extends Enumeration { val Signature = Value("sig") val Encryption = Value("enc") } trait PublicKeyUseJsonImplicits { implicit val publicKeyUseEncoder: Encoder[PublicKeyUse.Value] = Encoder.enumEncoder(P...
Explain and rewrite the following Scala code:
// Copyright (C) 2014 Fehmi Can Saglam (@fehmicans) and contributors. // See the LICENCE.txt 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 Licen...
Explain and rewrite the following Scala code:
import sbt._ import Keys._ object Build extends Build { import Dependencies._ val VERSION = "0.1" lazy val basicSettings = Seq( version := VERSION, homepage := Some(new URL("http://ptitjes.github.io/scott")), organization := "io.github.ptitjes", organizationHomepage := Some(new URL("http://ptitjes.github...
Explain and rewrite the following Scala code:
/* * Copyright 2015 * * 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 writing, ...
Explain and rewrite the following Scala code:
/** * Created by Mathieu Leclaire on 23/04/18. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero 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) 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 org.jetbrains.plugins.scala package lang package parser package parsing package expressions import com.intellij.psi.tree.IElementType import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes import org.jetbrains.plugins.scala.lang.parser.parsing.builder.ScalaPsiBuilder import org.jetbrains.plugins.scala.l...
Explain and rewrite the following Scala code:
package org.sgine.ui.event import org.sgine.ui.{FocusManager, Focusable} import org.powerscala.event.Event /** * @author Matt Hicks <mhicks@sgine.org> */ trait FocusEvent extends Event { def component: Focusable def focusManager: FocusManager } case class FocusGained(component: Focusable, focusManager: FocusM...
Explain and rewrite the following Scala code:
package com.datawizards.splot.builders import scala.collection.JavaConversions._ import com.datawizards.splot.configuration.SPlotDefaults import com.datawizards.splot.functions.AggregationFunction import com.datawizards.splot.mapper.SPlotToXChartMapper import com.datawizards.splot.model.PlotAxisValues.{XAxisValueType,...
Explain and rewrite the following Scala code:
/* * Copyright (C) 20011-2014 Scalable minds UG (haftungsbeschränkt) & Co. KG. <http://scm.io> */ package models import play.api.libs.json.Json case class RepositoryAccess(name: String, isAdmin: Boolean, isPusher: Boolean) object RepositoryAccess{ implicit val repositoryAccessFormat = Json.format[RepositoryAcces...
Explain and rewrite the following Scala code:
// Author: Dr Zhen He // // /Users/zhenhe/Documents/spark/spark-1.1.0/bin/spark-shell --master local[2] --driver-memory 8g def convertToSecsFromMidNight(time : String) : Int = { val splitTime = time.split(":").map(x => x.toInt) //require(splitTime(0) * 3600 + splitTime(1) * 60 + splitTime(2) > 0, "time string = " +...
Explain and rewrite the following Scala code:
package biology import locals._ trait Ontogeny { var ontogeny: OntogeneticState = getOntogeneticStateForAge(0) var recentlyDeveloped: Boolean = false def getOntogeneticStateForAge(age: Int): OntogeneticState } trait OntogenyFish extends Ontogeny { val hatching: Int val preflexion: Int val flexion: Int ...
Explain and rewrite the following Scala code:
package day2.traits /** * Created by Niels Bokmans on 22-3-2016. */ class Word(val word: String)
Explain and rewrite the following Scala code:
package reactor.core.scala import java.lang.{Boolean => JBoolean, Iterable => JIterable, Long => JLong} import java.time.{Duration => JDuration} import java.util.Optional import java.util.Optional.empty import java.util.concurrent.Callable import java.util.function.{BiConsumer, BiFunction, BooleanSupplier, Consumer, F...
Explain and rewrite the following Scala code:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may...
Explain and rewrite the following Scala code:
/* * 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.hydrosphere.mist.worker.runners import io.hydrosphere.mist.core.CommonData.RunJobRequest import io.hydrosphere.mist.worker.MistScContext import mist.api.data.JsData import scala.util._ trait JobRunner { def run(req: RunJobRequest, context: MistScContext): Either[Throwable, JsData] }
Explain and rewrite the following Scala code:
package com.olvind.crud package server import java.sql.Timestamp import slick.dbio.Effect.Write import slick.profile.FixedSqlAction trait updateNotifierChangelog extends integrationDb { trait UpdateNotifierChangelog { val changelogTableName = "crud_changelog" import driver.api._ implicit val m0 = Map...
Explain and rewrite the following Scala code:
package com.github.davidhoyt.playground.learn object Implicits extends App { //Implicit conversions class Foo(val x: String) class Bar(val x: Int) def giveMeAFoo(foo: Foo): Unit = println(foo.x) implicit def convertBarToFoo(bar: Bar): Foo = new Foo(bar.x.toString) implicit val bar = new Bar(111)...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.testingSupport.specs2.specs2_2_11_2_4_15 import org.jetbrains.plugins.scala.testingSupport.specs2.Specs2TestCase import org.jetbrains.plugins.scala.util.TestUtils.ScalaSdkVersion /** * @author Roman.Shein * @since 11.01.2015. */ trait Specs2_2_11_2_4_15_Base extends Specs2TestCa...
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 2013, Martin Pokorny <martin@truffulatree.org> // // 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 org.truffulatree.scampi3 import org.brid...
Explain and rewrite the following Scala code:
package de.sciss.mutagentx package visual import java.awt.Shape import java.awt.geom.Ellipse2D import de.sciss.lucre.event.Sys import prefuse.render.AbstractShapeRenderer import prefuse.visual.VisualItem import scala.swing.Graphics2D class NuagesShapeRenderer[S <: Sys[S]](size: Int) extends AbstractShapeRenderer ...
Explain and rewrite the following Scala code:
/* * Copyright 2017 Iaroslav Zeigerman * * 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:
package com.rocketfuel.sdbc.sqlserver import java.util.UUID import com.rocketfuel.sdbc.SqlServer._ class UUIDSpec extends SqlServerSuite { test("UUID survives a round trip") { implicit connection => val uuid = Some(UUID.randomUUID()) val selected = Select[Option[UUID]]("SELECT CAST(@uuid AS uniquei...
Explain and rewrite the following Scala code:
package org.jetbrains.jps.incremental.scala import _root_.java.util import java.io.File import java.util.concurrent.ConcurrentHashMap import com.intellij.openapi.util.Key import com.intellij.openapi.util.io.FileUtil import org.jetbrains.jps.ModuleChunk import org.jetbrains.jps.builders.java._ import org.jetbrains.jps...
Explain and rewrite the following Scala code:
object Test { def main(args: Array[String]): Unit = { val res = foo println(res) println(foo) } }
Explain and rewrite the following Scala code:
package org.brzy.webapp.service /** * This trait can be applied to service classes to make is automatically discoverable at * application startup. * * @author Michael Fortin */ trait Service { def serviceName = { val name = this.getClass.getSimpleName if (name.indexOf("_$$_javassist") != -1) nam...
Explain and rewrite the following Scala code:
package com.twitter.finagle.service import com.twitter.finagle.util.AsyncLatch import com.twitter.finagle.{Service, ServiceFactory, ClientConnection} import com.twitter.util.{Future, Promise, Time} /** * A [[com.twitter.finagle.ServiceFactory]] that produces * [[com.twitter.finagle.Service Services]] identical to t...
Explain and rewrite the following Scala code:
package v1.post.read import javax.inject.{Inject, Named} import akka.actor.{ActorRef, Props} import akka.persistence.query.EventEnvelope import akka.stream.ActorMaterializer import com.sksamuel.elastic4s.ElasticDsl._ import com.sksamuel.elastic4s.searches.queries.QueryDefinition import com.sksamuel.elastic4s.searches...
Explain and rewrite the following Scala code:
package views.html package coach import lila.api.Context import lila.app.templating.Environment._ import lila.app.ui.ScalatagsTemplate._ import lila.i18n.LangList import controllers.routes object widget { import trans.coach._ def titleName(c: lila.coach.Coach.WithUser) = frag( c.user.title.map { t =>...
Explain and rewrite the following Scala code:
import org.scalatest.WordSpec class ExampleSpec extends WordSpec { "A Set" when { "empty" should { "have size 0" in { assert(Set.empty.size == 0) } "produce NoSuchElementException when head is invoked" in { intercept[NoSuchElementException] { Set.empty.he...
Explain and rewrite the following Scala code:
package geotrellis.logic.applicative import geotrellis._ /** * This corresponds to Haskell's "fmap" on Functor. */ case class Fmap[A, Z:Manifest](a:Op[A])(f:A => Z) extends Op1[A, Z](a)(a => Result(f(a)))
Explain and rewrite the following Scala code:
package org.opencompare.api.java.io import org.opencompare.api.java.PCMFactory import org.opencompare.api.java.interpreter.CellContentInterpreter /** * Created by gbecan on 20/11/15. */ abstract class HtmlPCMCircularTest(val factory : PCMFactory, val cellContentInterpreter: CellContentInterpreter) extends PCMCirc...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2008, 2009, 2010 Mark Harrah */ package xsbt import xsbti.{ F0, Logger, Maybe } import java.io.File private object DelegatingReporter { def apply(settings: scala.tools.nsc.Settings, delegate: xsbti.Reporter): DelegatingReporter = new DelegatingReporter(Command.getWarnF...
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 com.bwsw.tstreamstransactionserver.netty import com.google.common.net.InetAddresses case class InetSocketAddressClass(address: String, port: Int){ override def toString: String = s"/$address:$port" } object InetSocketAddressClass { def isValidSocketAddress(inetAddress: String, port: Int): Boolean = { ...
Explain and rewrite the following Scala code:
/* * Copyright 2019 CJWW Development * * 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:
/* * 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 not use this f...
Explain and rewrite the following Scala code:
package edu.mit.cci.wikilanguage.model.active import org.apache.commons.httpclient.methods.GetMethod import org.jsoup.Jsoup import org.jsoup.nodes.Element import edu.mit.cci.util.U import scala.xml.XML /** * User: pdeboer * Date: 8/6/13 * Time: 7:39 PM * * rich class that fetches data from wikipedia if needed. s...
Explain and rewrite the following Scala code:
/* * This file is part of the ToolXiT 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 law or agreed t...
Explain and rewrite the following Scala code:
package io.iohk.ethereum.ledger import akka.util.ByteString import akka.util.ByteString.{empty => bEmpty} import io.iohk.ethereum.Mocks import io.iohk.ethereum.Mocks.MockVM import io.iohk.ethereum.consensus.Consensus import io.iohk.ethereum.consensus.ethash.validators.OmmersValidator import io.iohk.ethereum.consensus....
Explain and rewrite the following Scala code:
/* * Tranquility. * Copyright 2013, 2014, 2015 Metamarkets Group, 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...
Explain and rewrite the following Scala code:
package org.robbins.flashcards.akka.message import akka.actor.ActorRef import org.robbins.flashcards.SaveResultStatus import org.robbins.flashcards.dto.{AbstractAuditableDto, AbstractPersistableDto, BatchLoadingReceiptDto} import org.robbins.flashcards.facade.base.GenericCrudFacade object Messages { case class Ba...
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.usagram.clarify.validator import org.usagram.clarify.error.{ Errors, Error, ShouldBeLessThanOrEqualTo } import org.scalatest._ import org.scalatest.OptionValues._ class EachOfMapSpec extends FunSpec { import Matchers._ describe(".apply") { it("returns an EachOfMap with given validator") { ...
Explain and rewrite the following Scala code:
/* * Copyright 2019 Spotify AB. * * 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 rawObject object RawObject6 { def importedDef() = 2 }
Explain and rewrite the following Scala code:
package com.cloudray.scalapress.util.mvc.interceptor import org.springframework.web.servlet.handler.HandlerInterceptorAdapter import javax.servlet.http.{HttpServletResponse, HttpServletRequest} import com.cloudray.scalapress.settings.{InstallationDao, GeneralSettingsDao} import com.cloudray.scalapress.util.Scalate /*...
Explain and rewrite the following Scala code:
package scalan.examples import scalan._ import scalan.common.Default import scalan.common.OverloadHack.Overloaded1 trait MyArrays { self: ExampleDsl => /** * Optional type synonim to hide boilerplate of using Rep */ type MyArr[A] = Rep[MyArray[A]] /** * User defined type */ trait MyArray[A] exte...
Explain and rewrite the following Scala code:
package scalapb.compiler import org.scalatest.{FlatSpec, MustMatchers} class NameUtilsSpec extends FlatSpec with MustMatchers { "snakeCaseToCamelCase" should "work for normal names" in { NameUtils.snakeCaseToCamelCase("scala_pb") must be("scalaPb") NameUtils.snakeCaseToCamelCase("foo_bar") must be("fooBar")...
Explain and rewrite the following Scala code:
/* * * * Copyright (c) 2014-2016. National Institute of Advanced Industrial Science and Technology (AIST) * * All rights reserved. * */ package jp.go.aist.cspe import jp.go.aist.cspe.CSPE._ private[cspe] class Sequence(ps0 : List[Process]) extends Process { private def normalize (ps : List[Process]) : Lis...
Explain and rewrite the following Scala code:
package com.acme.book import com.acme.book.MetaModel._ case class Create(oid: ObjectId, diff: Diff) case class Update(oid: ObjectId, diff: Diff) case class Delete(oid: ObjectId, diff: Diff) case class Duplicate(oid1: ObjectId, oid2: ObjectId)
Explain and rewrite the following Scala code:
package scala.pickling package runtime import java.lang.reflect.Field import scala.reflect.runtime.{universe => ru} import ir._ import internal._ class RuntimeTypeInfo(classLoader: ClassLoader, clazz: Class[_], share: refs.Share) { import ru._ import definitions._ // debug(s"Initializing runtime type info f...
Explain and rewrite the following Scala code:
package spgui.widgets.examples import java.util.UUID import japgolly.scalajs.react._ import japgolly.scalajs.react.vdom.html_<^._ import spgui.SPWidgetBase import spgui.communication._ import scala.util.{Random, Try} // Import this to make SPAttributes work including json handling import sp.domain._ import Lo...
Explain and rewrite the following Scala code:
// // ConstraintSet.scala -- Scala class ConstraintSet // Project OrcScala // // $Id: ConstraintSet.scala 2933 2011-12-15 16:26:02Z jthywissen $ // // Created by dkitchin on Nov 28, 2010. // // Copyright (c) 2011 The University of Texas at Austin. All rights reserved. // // Use and redistribution of this file is govern...
Explain and rewrite the following Scala code:
// // pom-util - a Scala library for reading Maven POM files // http://github.com/samskivert/pom-util/blob/master/LICENSE package pomutil import scala.xml.NodeSeq /** * Some XML utilities. */ object XMLUtil { /** Returns the inner text of all elements in `node`. Generally this will be passed a node seq * th...
Explain and rewrite the following Scala code:
package org.datacleaner.beans import org.scalatest.junit.AssertionsForJUnit import org.junit.Test import org.datacleaner.data.MockInputColumn import org.datacleaner.data.MockInputRow import org.datacleaner.result.renderer.CrosstabTextRenderer import org.junit.Assert import org.datacleaner.storage.InMemoryRowAnnotationF...
Explain and rewrite the following Scala code:
package io.swagger.client.core sealed trait ResponseState object ResponseState { case object Success extends ResponseState case object Error extends ResponseState } case class ApiRequest[U]( // required fields method: ApiMethod, basePath: String...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2012 Romain Reuillon * * 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 program is di...
Explain and rewrite the following Scala code:
package chapter07 import java.io.FileReader import java.io.FileNotFoundException import java.io.IOException import java.net.MalformedURLException import java.net.URL /** * 7.4 try 표현식으로 예외 다루기 */ object c07_i04 extends App { /* * 1. 예외 발생시키기 */ val n = 2 //3 val half = if (n % 2 == 0) n / 2 ...
Explain and rewrite the following Scala code:
package libjoe.roshi import java.util.concurrent.ThreadLocalRandom sealed trait FarmStrategy[R <: LwwElementSet] { def insert(ksm: KeyScoreMember, clusters: IndexedSeq[Cluster[R]]): Boolean def delete(ksm: KeyScoreMember, clusters: IndexedSeq[Cluster[R]]): Boolean def select(key: String, clusters: IndexedSeq[Cl...
Explain and rewrite the following Scala code:
package com.avsystem.commons package mongo.core.ops trait KeyHandling extends Any { protected def key: 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:
object O { trait TypeTag type @@[O <: AnyRef, T <: TypeTag] = O with T sealed trait X extends TypeTag { type YTag <: TypeTag type Y = String @@ YTag } class F[Tag <: X] { type Y = Tag#Y def apply(): Y = null.asInstanceOf[Y] } trait ExampleTag extends X { override type YTag = Exampl...
Explain and rewrite the following Scala code:
package marge import marge.SeqDoubleFunctions.mean /** * * User: mikio * Date: 4/8/11 * Time: 4:03 PM */ class CrossValidation[X, Y](k: Int, data: Seq[(X, Y)]) { val n: Int = data.length val p: Seq[Seq[Int]] = CrossValidation.partition(k, n) val all: Range = 0 until n def evaluate[E](fct: (Seq[(X, Y)],...
Explain and rewrite the following Scala code:
package org.antipathy.mvn_scalafmt.model // $COVERAGE-OFF$ /** Class representing the result of a run of the plugin * @param totalFiles The total number of files checked * @param unformattedFiles The number of unformatted files in the project * @param fileDetails Details of each of the files */ case class Sum...
Explain and rewrite the following Scala code:
import java.util.Date import cassandra.{NbaResult, PlayerLine, ResultAdded, Total} import domain.formats.DomainEventFormats.{ResultAddedEvent, ResultFormat} import org.scalatest.{MustMatchers, WordSpec} class ProtobufSpec extends WordSpec with MustMatchers { //Sat Nov 03 05:00:00 MSK 2012 "parse config with a li...
Explain and rewrite the following Scala code:
package it.mocks import play.api.libs.json.Json case class TestType(foo: String, bar: Int) object TestType { implicit val testTypeFormat = Json.format[TestType] }
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang.adjustTypes import java.io.File import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.{CharsetToolkit, LocalFileSystem} import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil i...
Explain and rewrite the following Scala code:
import scala.tools.nsc.doc.model._ import scala.tools.nsc.doc.base._ import scala.tools.nsc.doc.base.comment._ import scala.tools.partest.ScaladocModelTest import java.net.{URI, URL} import java.io.File object Test extends ScaladocModelTest { override def code = """ |object Test { | val x = new Spa...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.failed.typeInference import org.jetbrains.plugins.scala.PerfCycleTests import org.jetbrains.plugins.scala.base.{ScalaLightCodeInsightFixtureTestAdapter, SimpleTestCase} import org.junit.experimental.categories.Category /** * @author Roman.Shein * @since 28.03.2016. */ @Catego...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Foundational Development * * 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 ...