instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package com.dt.scala.type_parameterization /** * @author Wang Jialin * Date 2015/7/11 * Contact Information: * WeChat: 18610086859 * QQ: 1740415547 * Email: 18610086859@126.com * Tel: 18610086859 */ //class P[+T](val first: T, val second: T) class P[+T](val first: T, val second: T){ // def replace...
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:
import akka.actor.{ PoisonPill, ActorRef, Props, Actor } /** * User: Björn Reimer * Date: 03.04.14 * Time: 17:20 * */ case class Start(repetitions: Int, requestRouter: ActorRef) case class CreateConversations() case class MakeEveryoneFriends() case class UserCreated(login: String, iid: String) case class Tok...
Explain and rewrite the following Scala code:
package ch03 import ch03.List.addCorrespondingElements import org.specs2.mutable.Specification class Ex322AddTwoListsSpec extends Specification{ "Add list elements" should { "add corresponding elements of two lists" in { addCorrespondingElements(List(1,2,3), List(4,5,6)) mustEqual List(5,7,9) } ...
Explain and rewrite the following Scala code:
def bimap[A, B, C, D](f: A => C)(g: B => D): ((A, B)) => (C, D)
Explain and rewrite the following Scala code:
package name.abhijitsarkar.scala import org.scalatest.matchers.{MatchResult, Matcher} import org.scalatest.prop.TableDrivenPropertyChecks._ import org.scalatest.prop.Tables.Table import org.scalatest.{FlatSpec, Matchers} import scala.reflect.runtime.{universe => ru} /** * @author Abhijit Sarkar */ class MyListSp...
Explain and rewrite the following Scala code:
/** * Illustrates a simple fold in scala */ package com.oreilly.learningsparkexamples.scala import org.apache.spark._ object BasicAvgWithKryo { def main(args: Array[String]) { val master = args.length match { case x: Int if x > 0 => args(0) case _ => "local" } val conf = new Sp...
Explain and rewrite the following Scala code:
import java.math.BigInteger import scala.annotation.tailrec /** * Fibonacci at any position is the sum of fibonacci at previous to positions: * Positions start at 0 * position 0 is returned by fib(0) and is 0, * position 1 is fib(1) = 1 and * fib(n) = fib(n-1) + fib(n-2) */ object ScalaFibonacci extends App{ ...
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.dwolla.cloudflare.domain.model import com.dwolla.circe._ import io.circe._ import io.circe.generic.semiauto import monix.newtypes.NewtypeWrapped import org.http4s.{QueryParam, QueryParamEncoder, QueryParameterKey, QueryParameterValue} package object wafrulepackages { type WafRulePackageName = WafRulePac...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.failed.annotator import org.jetbrains.plugins.scala.base.ScalaLightCodeInsightFixtureTestAdapter /** * @author Nikolay.Tropin */ class MissingParameterTypeTest extends ScalaLightCodeInsightFixtureTestAdapter { override protected def shouldPass: Boolean = false def testScl...
Explain and rewrite the following Scala code:
package com.twitter.finagle.benchmark import com.google.caliper.SimpleBenchmark import com.twitter.finagle.tracing.SpanId import scala.util.Random import com.twitter.util.RichU64Long // Run thus: ./pants goal bench finagle/finagle-benchmark --bench-target=com.twitter.finagle.benchmark.SpanIdBenchmark class SpanIdBen...
Explain and rewrite the following Scala code:
/* * Copyright 2014-2021 Netflix, 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 agr...
Explain and rewrite the following Scala code:
package berlin.jentsch.modelchecker.futures.example import berlin.jentsch.modelchecker.futures.EcSpec import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import scala.concurrent.Future class CompareAtomic extends AnyFlatSpec with EcSpec with Matchers { "without atomic" should "...
Explain and rewrite the following Scala code:
/* * -╥⌐⌐⌐⌐ -⌐⌐⌐⌐- * ≡╢░░░░⌐\\░░░φ ╓╝░░░░⌐░░░░╪╕ * ╣╬░░` `░░░╢┘ φ▒╣╬╝╜ ░░╢╣Q * ║╣╬░⌐ ` ╤▒▒▒Å` ║╢╬╣ * ╚╣╬░⌐ ╔▒▒▒▒`«╕ ╢╢╣▒ * ╫╬░░╖ .░ ╙╨╨ ╣╣╬░φ ╓φ░╢╢Å * ╙╢░░░░⌐"░░░╜ ╙Å░░░░⌐░░░░╝` * ``˚¬ ⌐ ˚˚⌐´ * * ...
Explain and rewrite the following Scala code:
package spinoco.protocol.http.header.value import scodec.Codec import scodec.codecs._ import spinoco.protocol.http.codec.helper._ import spinoco.protocol.mime.MIMECharset /** * Created by pach on 12/01/17. */ sealed trait HttpCharsetRange { self => import HttpCharsetRange._ def qValue: Option[Float] def ...
Explain and rewrite the following Scala code:
package singleton.ops import org.scalacheck.Properties import singleton.TestUtils._ class AndSpec extends Properties("&&") { property("truth table") = wellTyped { implicitly[Require[(True && True) == True]] implicitly[Require[(True && False) == False]] implicitly[Require[(False && True) == False]] i...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package resolve package processor import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.util.{Key, RecursionManager} import com.intellij.psi._ import com.intellij.psi.scope._ import org.jetbrains.plugins.scala.extensions._ import org.jetbrains...
Explain and rewrite the following Scala code:
package org.hammerlab.guacamole.logging import scala.collection.mutable /** * It's often useful to output counts of certain events that occur in RDD operations. The functions that operate on * RDDs, however, can't print these counters since the transformations they apply to the RDDs may not execute until * much...
Explain and rewrite the following Scala code:
//podemos usar estructuras iterativas da programacion imperativa //xa que scala non nos forza a usar o estilo funcional //inferencia do tipo //non implica que scala teña un tipado forte e statico var i = 0 while(i < args.length){ println(args(i)) //notar que non existe nos enteiros o ++ xa que vai encontra da fil...
Explain and rewrite the following Scala code:
package dao.impl import com.google.inject.{Inject, Singleton} import dao.DatabaseInitializer import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider} import slick.driver.JdbcProfile import slick.driver.H2Driver.api._ import slick.profile.SqlAction import scala.concurrent.{ExecutionContext, Future}...
Explain and rewrite the following Scala code:
package com.backhoff.clustream /** * Created by omar on 9/18/15. */ import org.apache.spark.streaming.dstream.DStream import org.apache.spark.streaming.scheduler.{StreamingListenerBatchCompleted, StreamingListener} import org.apache.spark.streaming.{Milliseconds, StreamingContext} import org.apache.spark.{SparkCont...
Explain and rewrite the following Scala code:
package com.github.jmcs.domain.types object ValueType extends Enumeration { val STRING = Value val INTEGER = Value val FLOAT = Value val BOOLEAN = Value val DATETIME = Value val VARIABLE = Value val SEQUENCE_VARIABLE = Value }
Explain and rewrite the following Scala code:
import scala.io.Source import scala.util.parsing.combinator.Parsers import scala.util.parsing.input.Reader import scala.util.parsing.input.Position import org.junit.Test import org.junit.Assert.assertEquals class T5514 extends Parsers { var readerCount = 0 class DemoReader(n: Int) extends Reader[String] { def...
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 2011-2021 Asakusa Framework Team. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
Explain and rewrite the following Scala code:
class SelfInvocation(x: Int, y: Int) { def this(s: String) { this(1, 2) } def this(x: Int) { this(/*caret*/) } def this(b: Boolean) { this("text") } } /* s: String x: Int, y: Int */
Explain and rewrite the following Scala code:
import scala.util.control.NonLocalReturns.* extension [T, E <: Throwable](op: => T) inline def rescue (fallback: PartialFunction[E, T]) = try op catch { case ex: ReturnThrowable[_] => throw ex case ex: E => if (fallback.isDefinedAt(ex)) fallback(ex) else throw ex } def test: Unit = ...
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 manipulators /** NgramSplitter splits plain strings into ngrams and provides utilities for calculating min overlap and search range * * @constructor create list of ngrams * @param plainstr Original string */ class NgramSplitter(plainstr: String) { val str = plainstr; var grams = List[String](); /*...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Webtrends (http://www.webtrends.com) * * 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 License. * Yo...
Explain and rewrite the following Scala code:
package com.sageserpent package object americium { object seqEnrichment extends SeqEnrichment object randomEnrichment extends RandomEnrichment }
Explain and rewrite the following Scala code:
package nl.dekkr.pagefetcher import nl.dekkr.pagefetcher.model.PageUrl import org.specs2.mutable.Specification class PageUrlSpec extends Specification { " PageUrl" should { "fail on a empty url " in { PageUrl(url = "") must throwAn[Exception] } "fail on a invalid protocol in the url " in { ...
Explain and rewrite the following Scala code:
package v2d2.actors.comedy import fastparse._, SingleLineWhitespace._ import v2d2.actors.core.BotCombinators import slack.models.Message case class GetTargets() case class GetResponses() case class Targets( trgs: Map[String, Joke] ) case class Responses( trgs: Map[String, NewJoke] ) case class Joke( target: St...
Explain and rewrite the following Scala code:
/** RLTools is a library for reinforcement learning methods. Copyright (C) 2013 Petteri Mehtala (petteri.mehtala@gmail.com) 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, e...
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.eso.ias.dasu.executorthread import java.util.concurrent.ThreadFactory import org.eso.ias.utils.ISO8601Helper /** The thread factory for the DASU */ class DasuThreadFactory(private val dasuId: String) extends ThreadFactory { require(Option(dasuId).isDefined && !dasuId.isEmpty(),"Invalid ID of the DASU") ...
Explain and rewrite the following Scala code:
class LazyInput { def foo { lazy val x = 44 /*start*/ x + 77 /*end*/ } } /* class LazyInput { def foo { lazy val x = 44 /*start*/ testMethodName(x) /*end*/ } def testMethodName(x: => Int) { x + 77 } } */
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package codeInspection.methodSignature import com.intellij.codeInspection.LocalInspectionTool import org.jetbrains.plugins.scala.codeInspection.{InspectionBundle, ScalaLightInspectionFixtureTestAdapter} /** * Nikolay.Tropin * 6/25/13 */ class DeclarationHasNoExplicitTypeInspecti...
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 com.twitter.finagle.memcached.unit.protocol.text.client import com.twitter.finagle.memcached.protocol.text.client.ClientDecoder import com.twitter.finagle.memcached.protocol.text.{ Decoding, StatLines, Tokens, TokensWithData, ValueLines } import com.twitter.io.Buf import org.scalatest.FunSuite import...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2015 Contributor. All rights reserved. */ package org.scalaide.debug.internal.expression package features import org.junit.Test import org.scalaide.debug.internal.expression.Names.Java class NamedParametersTest extends BaseIntegrationTest(NamedParametersTest) { @Test def standardMethod(): Un...
Explain and rewrite the following Scala code:
/* * Copyright 2013 http4s.org * * 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 com.twitter.finagle.mysql.unit package harness import com.twitter.finagle.mysql.harness.EmbeddedDatabase import com.twitter.finagle.mysql.harness.EmbeddedInstance import com.twitter.finagle.mysql.harness.config.DatabaseConfig import com.twitter.finagle.mysql.harness.config.User import java.util.UUID import org...
Explain and rewrite the following Scala code:
/* Copyright 2009-2014 EPFL, Lausanne */ package leon.custom import leon._ import leon.lang._ import leon.collection._ import leon.annotation._ sealed abstract class List[T] { def size: BigInt = (this match { case Nil() => BigInt(0) case Cons(h, t) => BigInt(1) + t.size }) ensuring (_ >= 0) def conten...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2008, 2009, 2010 Mark Harrah */ package sbt import java.io.File import java.net.URL import org.apache.ivy.core.cache.{ ArtifactOrigin, CacheDownloadOptions, DefaultRepositoryCacheManager } import org.apache.ivy.core.module.descriptor.{ Artifact => IvyArtifact, DefaultArtifac...
Explain and rewrite the following Scala code:
package org.genericConfig.admin.client.views.config import org.genericConfig.admin.client.controllers.listner.Mouse import org.genericConfig.admin.client.controllers.websocket.ActionsForClient import org.genericConfig.admin.client.views.html.{HtmlElementIds, HtmlElementText} import org.genericConfig.admin.shared.confi...
Explain and rewrite the following Scala code:
// object Test compiles jointly, but not separately. object Test { import Scalaz._ Scalaz.a }
Explain and rewrite the following Scala code:
package cn.changhong.orm /** * Created by yangguo on 14-10-28. */
Explain and rewrite the following Scala code:
/* - Coeus web framework ------------------------- * * Licensed under the Apache License, Version 2.0. * * Author: Spiros Tzavellas */ package com.tzavellas.coeus.spring package test import javax.servlet.ServletConfig import com.tzavellas.coeus.core.config._ import config.SpringSupport class SpringWebModule(sc: ...
Explain and rewrite the following Scala code:
package featherbed import java.nio.charset.Charset import cats.data.ValidatedNel import cats.implicits._ import io.circe._ import io.circe.generic.auto._ import io.circe.parser._ import io.circe.syntax._ import shapeless.Witness package object circe { private val printer = Printer.noSpaces.copy(dropNullValues = t...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2020 MapRoulette contributors (see CONTRIBUTORS.md). * Licensed under the Apache License, Version 2.0 (see LICENSE). */ package org.maproulette.framework.model import org.joda.time.DateTime import org.maproulette.framework.psql.CommonField import org.maproulette.data.{UserType} import play.api.li...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.codeInspection.collections import org.jetbrains.plugins.scala.codeInspection.InspectionBundle import org.jetbrains.plugins.scala.lang.psi.api.expr.ScExpression import org.jetbrains.plugins.scala.lang.psi.types.api.ParameterizedType import org.jetbrains.plugins.scala.lang.psi.types.r...
Explain and rewrite the following Scala code:
package xyz.hyperreal.sprolog import xyz.hyperreal.rtcep.Position abstract class AST { var _pos: Position = null def pos( p: Position ) = { _pos = p this } def pos = _pos } case class AtomAST( atom: Symbol ) extends AST case class NumberAST( n: Number ) extends AST case class StringAST( s: String ) ext...
Explain and rewrite the following Scala code:
package lert.core.cache import lert.core.cache.GuavaCache.Key import com.google.common.cache.CacheBuilder trait GlobalCache { def get[K, V](resourceType: String, key: K, value: => V): V } class GuavaCache extends GlobalCache { private val cache = CacheBuilder.newBuilder.build[Object, Object]() override def g...
Explain and rewrite the following Scala code:
package org.scalaide.debug.internal.model import com.sun.jdi.ClassType import com.sun.jdi.IncompatibleThreadStateException import com.sun.jdi.Method import com.sun.jdi.ObjectCollectedException import com.sun.jdi.ObjectReference import com.sun.jdi.ThreadReference import com.sun.jdi.Value import com.sun.jdi.VMCannotBeMo...
Explain and rewrite the following Scala code:
package org.rebeam.boxes.fx.demo import scalafx.Includes._ import scalafx.application.JFXApp import scalafx.application.JFXApp.PrimaryStage import scalafx.scene.Scene import scalafx.scene.paint.Color import scalafx.scene.layout.GridPane import scalafx.geometry.Insets import scalafx.scene.control._ import scalafx.scen...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package completion import scala.annotation.tailrec import com.intellij.codeInsight.completion._ import com.intellij.codeInsight.lookup.{InsertHandlerDecorator, LookupElement, LookupElementDecorator} import com.intellij.openapi.editor.Document import com.intellij.patter...
Explain and rewrite the following Scala code:
package grasshopper.elasticsearch import java.io.File import java.nio.file.Files import com.typesafe.scalalogging.Logger import org.elasticsearch.client.Client import org.elasticsearch.common.settings.ImmutableSettings import org.elasticsearch.action.search.SearchType import org.elasticsearch.index.query.QueryBuilders...
Explain and rewrite the following Scala code:
package helpers import org.specs2.mutable.Specification import renesca.schema.macros.{Aborter, Code, Generators, Patterns, Warner} trait CodeComparisonSpec extends Specification with ContextMock with CompileSpec with Colors { sequential trait ExpectedCode case class With(code: String) extends ExpectedCode ...
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.nekopiano.scala.sandbox.spec.specs2 import org.specs2.mutable.Specification /** This is the "Unit" style for specifications */ class HelloWorldUnitStyleSpec extends Specification { "This is a specification for the 'Hello world' string".txt "The 'Hello world' string should" >> { "contain 11 charac...
Explain and rewrite the following Scala code:
package recfun import common._ object Main { def main(args: Array[String]) { println("Pascal's Triangle") for (row <- 0 to 10) { for (col <- 0 to row) print(pascal(col, row) + " ") println() } } /** * Exercise 1 */ def pascal(c: Int, r: Int): Int = (c + 1 to r).product / ...
Explain and rewrite the following Scala code:
import java.io.File import testgen.TestSuiteBuilder import testgen.TestSuiteBuilder.fromLabeledTestFromInput object RaindropsTestGenerator { def main(args: Array[String]): Unit = { val file = new File("src/main/resources/raindrops.json") val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("num...
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:
/*********************************************************************** * 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 controllers import _root_.util.html.HtmlExtension._ import _root_.util.security._ import models._ import play.api.Play.current import play.api.data.Forms._ import play.api.data._ import play.api.i18n.Messages import play.api.i18n.Messages.Implicits._ import play.api.libs.json.{JsNumber, _} import play.api.mvc....
Explain and rewrite the following Scala code:
/** * Copyright 2019 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 * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Explain and rewrite the following Scala code:
/* NEST (New Scala Test) * Copyright 2007-2013 LAMP/EPFL * @author Philipp Haller */ // $Id$ package scala.tools.partest package nest import java.io.{ File, FilenameFilter, IOException, StringWriter, FileInputStream, FileOutputStream, BufferedReader, FileReader, PrintWriter, FileWriter } impor...
Explain and rewrite the following Scala code:
package org.apache.spark.ml.dsl.utils.refl import org.apache.spark.sql.catalyst.ScalaReflection.universe._ import org.apache.spark.sql.types._ /** * Can only exist in DataRowSchema & extractor to remember ScalaType * Not allowed to be used in DataFrame schema * WARNING: this cannot be completely superceded by S...
Explain and rewrite the following Scala code:
package com.wavesplatform.lang.v1.repl.impl import scala.scalajs.js import scala.scalajs.js.annotation.JSGlobalScope import scala.scalajs.js.{Object, Promise, native} @native @JSGlobalScope object Global extends Object { def httpGet(params: js.Dynamic): Promise[js.Dynamic] = native }
Explain and rewrite the following Scala code:
package org.nefilim.influxdb import akka.actor.{ActorSystem, Props} import akka.testkit.TestKit import com.typesafe.scalalogging.slf4j.LazyLogging import nl.grons.metrics.scala.MetricName import org.scalatest.{BeforeAndAfterAll, WordSpecLike} import scala.concurrent.duration._ import scala.language.implicitConversion...
Explain and rewrite the following Scala code:
package com.lynbrookrobotics.potassium import com.lynbrookrobotics.potassium.tasks.{FiniteTask, Task} import org.scalatest.{BeforeAndAfter, FunSuite} class TaskTest extends FunSuite with BeforeAndAfter { after { Task.abortCurrentTask() } test("Single task execute and abort") { var started = false v...
Explain and rewrite the following Scala code:
case class Todo(id: String, title: String, description: String, done: Boolean) case class CreateTodo(title: String, description: String) case class UpdateTodo(title: Option[String], description: Option[String], done: Option[Boolean])
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 kafka.console package object model { type Token = String }
Explain and rewrite the following Scala code:
package cmwell.analytics.main import cmwell.analytics.data.{IndexWithSystemFields, Spark} import cmwell.analytics.util.CmwellConnector import org.apache.log4j.LogManager import org.apache.spark.sql.DataFrame import org.joda.time.format.ISODateTimeFormat import org.rogach.scallop.{ScallopConf, ScallopOption, ValueConve...
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 jigg.pipeline /* Copyright 2013-2016 Hiroshi Noji 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...
Explain and rewrite the following Scala code:
package com.yourtion.Pattern13 import com.yourtion.Pattern13.Phases._ import scala.util.control.TailCalls._ /** * Created by Yourtion on 01/04/2017. */ object EvenOdd { def isOdd(n: Long): Boolean = if (n == 0) false else isEven(n - 1) def isEven(n: Long): Boolean = if (n == 0) true else isOdd(n - 1) d...
Explain and rewrite the following Scala code:
package fr.laas.fape.anml.model import fr.laas.fape.anml.model.abs.Mod import fr.laas.fape.anml.model.concrete.statements.Statement import fr.laas.fape.anml.model.concrete.{InstanceRef, RefCounter, _} import fr.laas.fape.anml.model.ir._ import fr.laas.fape.anml.parser.{SetExpr, Action => _, _} import fr.laas.fape.anml...
Explain and rewrite the following Scala code:
package gitbucket.core.util import gitbucket.core.model.Account import SyntaxSugars._ import gitbucket.core.service.SystemSettingsService import gitbucket.core.service.SystemSettingsService.Ldap import com.novell.ldap._ import java.security.Security import org.slf4j.LoggerFactory import scala.annotation.tailrec /** ...
Explain and rewrite the following Scala code:
package com.github.novamage.svalidator.validation /** * Provides information about errors occurred during the validation process */ trait ValidationResult[+A] { def validationFailures: List[ValidationFailure] def data: Option[A] /** Returns true if no failures occurred */ def isValid: Boolean = vali...
Explain and rewrite the following Scala code:
package model import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import spray.json.{DefaultJsonProtocol, RootJsonFormat} /** * Here are all matterbridge defined entities */ object MatterBridgeEntities { case class SlashResponseField(title: String, value: String, short: Boolean = false) case clas...
Explain and rewrite the following Scala code:
package databench.squeryl import org.squeryl.KeyedEntity import databench.Bank import databench.AccountStatus import org.squeryl.Schema import java.sql.DriverManager import org.squeryl.PrimitiveTypeMode._ import org.squeryl.adapters.MySQLAdapter import org.squeryl.adapters.PostgreSqlAdapter import org.squeryl.internal...
Explain and rewrite the following Scala code:
package test import biz.enef.angulate.{angular, Scope, Module} import scala.scalajs.js import scala.scalajs.js.UndefOr import js.Dynamic.literal import Module.RichModule object TestHelpers { /** * Returns the dependency with the specified name from the (implicitly) specified module. * * @param name * ...
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.concurrency.ch3 import java.util.concurrent.atomic import scala.annotation.tailrec class TreiberStack[T] { class Node(val v:T, var next:Node) private val head = new atomic.AtomicReference[Node] @tailrec final def push(x:T): Unit = { val oldhead = this.head.get val newhead = new Node(x, o...
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.jetbrains.sbt package project.settings import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings import org.jetbrains.annotations.Nullable import scala.beans.BeanProperty /** * @author Pavel Fatin */ class SbtProjectSettings extends ExternalProjectSettings { super.setUseAutoImport(...
Explain and rewrite the following Scala code:
package org.wquery.lang import java.io.{BufferedWriter, OutputStream, OutputStreamWriter} import jline.console.ConsoleReader import org.rogach.scallop.Scallop import org.wquery.emitter.WQueryEmitter import org.wquery.model.WordNet class WQueryLanguageMain(languageName: String, language: WordNet => WLanguage) extends...
Explain and rewrite the following Scala code:
package wandou.avro import java.io.ByteArrayInputStream import java.io.IOException import org.apache.avro.Schema import org.apache.avro.Schema.Type import org.apache.avro.generic.GenericData import org.apache.avro.generic.GenericDatumReader import org.apache.avro.io.DecoderFactory import org.apache.avro.specific.Speci...
Explain and rewrite the following Scala code:
package com.twitter.finagle.netty4 import io.netty.buffer.ByteBuf import io.netty.util.{ResourceLeakDetector, ResourceLeakDetectorFactory} import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ import org.mockito.Matchers._ import org.scalatest.funsuite.AnyFunSuite class StatsLeakDetectorFactoryTe...
Explain and rewrite the following Scala code:
package org.orbeon.oxf.fr object FormRunner extends FormRunnerCommon with FormBuilderPermissionsOps with FormRunnerPDF with FormRunnerEmailBackend with FormRunnerSummary with FormRunnerHome with FormRunnerPublish with FormRunnerEncodeDecode
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package impl package base package types import com.intellij.lang.ASTNode import com.intellij.psi.{PsiElement, PsiElementVisitor, ResolveState} import org.jetbrains.plugins.scala.extensions.TraversableExt import org.jetbrains.plugins.scala.lang.psi.api.ScalaE...
Explain and rewrite the following Scala code:
// Copyright: 2010 - 2017 https://github.com/ensime/ensime-server/graphs // License: http://www.gnu.org/licenses/gpl-3.0.en.html package org.ensime.fixture import java.io.File import scala.collection.immutable.Queue import scala.tools.nsc.Settings import scala.tools.nsc.interactive.Global import akka.actor.ActorSyst...
Explain and rewrite the following Scala code:
package com.peterpotts.mancala case class SideCup(id: Int, cup: Cup)
Explain and rewrite the following Scala code:
package com.github.acrisci.commander.errors class InvalidCommandException(message: String) extends RuntimeException { }
Explain and rewrite the following Scala code:
package com.github.mdr.ascii.layout.cycles import org.scalatest.{ Matchers, FlatSpec } import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.util.Utils class GraphReflowTest extends FlatSpec with Matchers { reflowingGraph(""" +-+ +-+ |A|-->|B| +-+ +-+ """). inOrd...
Explain and rewrite the following Scala code:
package de.kalass.batchmonads.example import de.kalass.batchmonads.base.BatchOperation import de.kalass.batchmonads.base.Operation class CustomerServiceImpl extends CustomerService { private val getCustomers: BatchOperation[Long, Customer] = BatchOperation.create({ ids => { println("getCusto...