instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
/* * Copyright (c) 2012-2014 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
Explain and rewrite the following Scala code:
package adt.bson.mongo.client import adt.bson.BsonObject import com.mongodb.client.MongoDatabase import scala.language.implicitConversions trait ClientImplicits { implicit def toBsonDatabaseOps(db: MongoDatabase): BsonDatabaseOps = new BsonDatabaseOps(db) } class BsonDatabaseOps(val db: MongoDatabase) extends An...
Explain and rewrite the following Scala code:
/* ASIB - A Scala IRC Bot Copyright (C) 2012 Iain Cambridge 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 versio...
Explain and rewrite the following Scala code:
package mesosphere.marathon package integration import mesosphere.AkkaIntegrationTest import mesosphere.marathon.integration.facades.ITEnrichedTask import mesosphere.marathon.integration.setup._ import mesosphere.marathon.raml.App import mesosphere.marathon.state.PathId._ import org.scalatest.Inside import scala.conc...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.requests.cat import com.sksamuel.elastic4s.Indexes case class CatSegments(indices: Indexes)
Explain and rewrite the following Scala code:
package zoey import org.scalatest.FunSpec class ZNodeOrderingSpec extends FunSpec { describe("ZNode ordering") { it ("should support sequential ordering by default") { val a = ZNode(null, s"/x-000") val b = ZNode(null, s"/x-11") val c = ZNode(null, s"/x-102") assert(Seq(c, b, a).sorted =...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang.psi.light.scala import com.intellij.psi.impl.light.LightElement import com.intellij.psi.{PsiAnnotation, PsiClass, PsiElement} import org.jetbrains.plugins.scala.lang.psi.ScalaPsiElement import org.jetbrains.plugins.scala.lang.psi.api.base.ScModifierList import org.jetbr...
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:
/* * Copyright 2012 Twitter 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 t...
Explain and rewrite the following Scala code:
package stefanholzmueller.pp2.check import stefanholzmueller.pp2.util.Dice import stefanholzmueller.pp2.util.IntTriple import stefanholzmueller.pp2.util.Timer import stefanholzmueller.pp2.util.Timer.time import scala.collection.mutable.ListBuffer class ParallelStatisticsCalculatorAdapter extends StatisticsGat...
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:
import scala.io._ object ex2{ def main(args: Array[String]): Unit = { object Factorial{ def computeFactorial(num : Int) :BigInt = { var i : Int = 0 var fact : BigInt = 1 for( i <- 1 to num) { fact *= i } fact } def computeFactorialRecursion(num : Int) : BigInt= { if(num == ...
Explain and rewrite the following Scala code:
package com.datastax.driver.spark.rdd.reader import java.lang.reflect.Method import com.datastax.driver.core.Row import com.datastax.driver.spark.connector.TableDef import com.datastax.driver.spark.mapper._ import com.datastax.driver.spark.types.{TypeConversionException, TypeConverter} import scala.reflect.runtime.u...
Explain and rewrite the following Scala code:
/** * Copyright 2015 Thomson Reuters * * 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 ag...
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.plugins.scala.lang.typeInference import org.jetbrains.plugins.scala.base.ScalaLightCodeInsightFixtureTestAdapter class HKExpectedTypeConformanceTest extends ScalaLightCodeInsightFixtureTestAdapter { def testSCL13042(): Unit = { val text = """ |def f[R[_], T](fun: String => R[...
Explain and rewrite the following Scala code:
import sbt._ object PluginDef extends Build { lazy val root = Project("plugins", file(".")) dependsOn(buildPlugin, yuiCompressorPlugin) lazy val buildPlugin = uri("git://github.com/lift/sbt-lift-build.git#724fb133beac77bbd06d3fb8ea086a1c88ee2a7d") lazy val yuiCompressorPlugin = uri("git://gith...
Explain and rewrite the following Scala code:
package com.lightning.walletapp.lnutils import spray.json._ import android.database.sqlite._ import com.lightning.walletapp.ln.PaymentInfo._ import com.lightning.walletapp.lnutils.ImplicitJsonFormats._ import com.lightning.walletapp.ln.Tools.{random, runAnd} import com.lightning.walletapp.lnutils.olympus.CloudData imp...
Explain and rewrite the following Scala code:
package com.lyrx.latex import java.util.Locale import com.lyrx.text.Context /** * Created by alex on 05.11.16. */ class SimpleLetter (override val config:LetterConfig) extends Letter
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014, Brook 'redattack34' Heisler * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, t...
Explain and rewrite the following Scala code:
package com.avsystem.commons package hocon import com.avsystem.commons.annotation.explicitGenerics import com.avsystem.commons.serialization._ import com.typesafe.config.{ConfigValue, ConfigValueFactory} object HoconOutput { @explicitGenerics def write[T: GenCodec](value: T): ConfigValue = { var result: Confi...
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 jsky.app.ot.shared.spModel.util import edu.gemini.pot.spdb.{IDBDatabaseService, IDBFunctor, IDBQueryRunner} import edu.gemini.pot.sp.{ISPRootNode, ISPNode} import edu.gemini.pot.spdb.IDBFunctor.Priority import edu.gemini.spModel.core.{Peer, SPProgramID} import edu.gemini.spModel.data.ISPDataObject import edu.g...
Explain and rewrite the following Scala code:
package nexus.diff import shapeless.{HList, Nat} /** * Base trait for all modules. * Modules serve as basic building blocks of neural network that may contain parameters. * * A module should always be implemented as an instance of the trait `Product`, preferably as a '''case class''': * This enables recursive tr...
Explain and rewrite the following Scala code:
package com.seanshubin.learn.datomic.prototype import java.lang.{Boolean => JavaBoolean, Long => JavaLong} import java.time.Instant import java.util.Date import clojure.lang.Keyword import com.seanshubin.learn.datomic.prototype.EntityAttributeValue.OrderByEntityAttributeValue trait EntityAttributeValue extends Order...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2015 Stratio (http://stratio.com) * * 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 ap...
Explain and rewrite the following Scala code:
package dotty.tools.dotc package transform import TreeTransforms._ import core.DenotTransformers._ import core.Symbols._ import core.Contexts._ import core.Types._ import core.Flags._ import core.Decorators._ import core.StdNames.nme import core.Names._ import core.NameOps._ import ast.Trees._ import SymUtils._ import...
Explain and rewrite the following Scala code:
package org.eigengo.phillyete.core import scala.io.Source trait SentimentSets { def positiveWords: Set[String] def negativeWords: Set[String] } trait CSVLoadedSentimentSets extends SentimentSets { lazy val positiveWords = loadWords("/positive_words.csv") lazy val negativeWords = loadWords("/negative_words.cs...
Explain and rewrite the following Scala code:
/* __ *\\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** ** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\\___/_/...
Explain and rewrite the following Scala code:
package net.walend.disentangle.graph.semiring import org.scalatest.{Matchers, FlatSpec} import net.walend.disentangle.graph.SomeGraph import SomeGraph._ /** * Tests algorithms with FewestNodes * * @author dwalend * @since v0.1.0 */ class FewestNodesTest extends FlatSpec with Matchers { "Initializing the labe...
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 com.sksamuel.elastic4s.http.search.queries.term import com.sksamuel.elastic4s.ElasticDate import com.sksamuel.elastic4s.json.{XContentBuilder, XContentFactory} import com.sksamuel.elastic4s.searches.queries.RangeQuery object RangeQueryBodyFn { def apply(range: RangeQuery): XContentBuilder = { val buil...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Frugal Mechanic (http://frugalmechanic.com) * * 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...
Explain and rewrite the following Scala code:
package com.mentatlabs.nsa package scalac package options /* -Xexperimental * ============== * 2.2.0 - 2.5.1: enable experimental extensions * 2.6.0 - 2.8.2: Enable experimental extensions * 2.9.0 - 2.12.0: Enable experimental extensions. */ case object ScalacXExperimental extends ScalacOptionBoole...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2010 Romain Reuillon * * 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 progra...
Explain and rewrite the following Scala code:
/* * Copyright 2016 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:
/* * 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.github.tailhq.dynaml.utils.sumac import io.github.tailhq.dynaml.utils.sumac.validation.Required import scala.annotation.tailrec import java.lang.reflect.{Type, Field} import collection.mutable.LinkedHashMap import collection._ class ArgumentParser[T <: ArgAssignable] (val argHolders: Seq[T]) { lazy val ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package play.it import org.slf4j.LoggerFactory import ch.qos.logback.core.AppenderBase import ch.qos.logback.classic.spi.ILoggingEvent import scala.collection.mutable.ListBuffer import ch.qos.logback.classic.{ Logger, LoggerContext, Level } /**...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2017. Yuriy Stul */ package com.stulsoft.scala.math.interpolation /** * Y = Y0 + (X - X0)*(Y1 - Y0)/(X1 - X0) * * @param points sequence of points (x, y) * @author Yuriy Stul */ protected case class PiecewiseLinearInterpolation(var points: Seq[(Double, Double)]) extends Interpolation{ ...
Explain and rewrite the following Scala code:
package remoting import akka.actor._ import com.typesafe.config.ConfigFactory import gpio4s.pi4j._ import gpio4s.{PiModels, Pi, Subscribe} /** * remote actor subscribes to pi * @author wassj */ object SubscribeToRemotePin { val pin = 1 def main(args: Array[String]) { val config = ConfigFactory.loa...
Explain and rewrite the following Scala code:
// Copyright 2012,2013,2014 Jun Tsai. All rights reserved. // site: http://www.ganshane.com package shakey.services import java.util.Properties import java.io.{IOException, BufferedInputStream} import org.slf4j.Logger /** * 输出版本 * @author jcai */ trait BootstrapTextSupport { protected[shakey] def printText(text:...
Explain and rewrite the following Scala code:
package test import java.io.FileWriter object ScalaTest { def main(args: Array[String]): Unit = { (new ScalaTest).foo() } } class ScalaTest { def foo(): Unit = { val writer = new FileWriter("launchDelegate.result") writer.write("success") writer.close } }
Explain and rewrite the following Scala code:
package build object DocumentationFactory { private lazy val docsBuilder = new MultipleDocTypesBuilder with DirectoryHandlerImpl with GitRepositoryService with LuceneDocsIndexer with LuceneDocsSearcher def documentsBuilder: DocsBuilder = { docsBuilder } def repositoryService: RepositoryService = { ...
Explain and rewrite the following Scala code:
package org.improving.scalify import Scalify._ import org.eclipse.jdt.core.dom // import scalaz.OptionW._ class STDWithFactory(node: dom.TypeDeclaration) extends TypeDeclaration(node) with ConstructorArrangement { override def emitNew: Emission = Nil def mergedTypeParameters(con: Constructor): Emission = TYPEARGS(...
Explain and rewrite the following Scala code:
package com.socrata.soda.server import java.io.Closeable import com.socrata.http.client._ class HeaderAddingHttpClient(underlying: HttpClient, extraHeaders: Iterable[(String, String)]) extends HttpClient { override def close() = underlying.close() override def executeRawUnmanaged(req: SimpleHttpRequest): RawRes...
Explain and rewrite the following Scala code:
/* * ScalaRay - Ray tracer based on pbrt (see http://pbrt.org) written in Scala * Copyright (C) 2009, 2010, 2011 Jesper de Jong * * 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 ve...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package api package base package literals trait ScBooleanLiteral extends ScLiteral { override protected type V = java.lang.Boolean override final def isSimpleLiteral: Boolean = true } object ScBooleanLiteral { def unapply(literal: ScBooleanLiteral):...
Explain and rewrite the following Scala code:
package no.netcompany.testdatagen.generators.misc // Copyright (C) 2014 Lars Reed -- GNU GPL 2.0 -- see LICENSE.txt import no.netcompany.testdatagen.ExtendedGenerator import org.junit.runner.RunWith import org.scalatest.FlatSpec import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) class CarMakesSpec...
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 it.agilelab.bigdata.spark.search import java.util.Date import scala.math._ sealed abstract class Field[T](val name: String, val value: T) extends Serializable { override def toString = { val string = value.toString "(" + name + "," + string.substring(0, min(string.length, 32)) + ")" } } case class St...
Explain and rewrite the following Scala code:
package com.mwronski.flink.batch import org.apache.flink.api.scala._ /** * Count words based on given text using batch approach. */ object BatchWordCount { def main(args: Array[String]) { val env = ExecutionEnvironment.getExecutionEnvironment val text = env.fromElements( "To be, or not to be,--t...
Explain and rewrite the following Scala code:
package org.zalando.jsonapi.json.circe import io.circe.Json import io.circe.parser.parse import io.circe.syntax._ import org.scalatest.MustMatchers import org.zalando.jsonapi.json.JsonBaseSpec import org.zalando.jsonapi.model._ class CirceJsonapiFormatSpec extends JsonBaseSpec[Json] with MustMatchers with CirceJsonap...
Explain and rewrite the following Scala code:
package uk.gov.dvla.vehicles.presentation.common.clientsidesession import java.security.SecureRandom object ByteGenerator { /** * Creates an array of randomly generated bytes * * @param numberOfBytes the size of the random byte array * @return a random byte array whose size is specified by the numb...
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:
/* * 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 com.lucaswilkins.newtonfractals import com.lucaswilkins.newtonfractals.complex._ /** * Created by lucas on 15/11/2014. */ object util { /** * Zip two lists, when they are different lengths pad the shortest * to a default value * * @param list1 First list * @param list2 Second lis...
Explain and rewrite the following Scala code:
package io.vamp.model.conversion import io.vamp.model.artifact._ import scala.language.implicitConversions object DeploymentConversion { implicit def deploymentConversion(deployment: Deployment): DeploymentConversion = new DeploymentConversion(deployment) } class DeploymentConversion(val deployment: Deployment) {...
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 * * Copyright (c) 2016 Fulcrum Genomics LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to us...
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 controllers.admin import java.util.concurrent.TimeoutException import scala.concurrent.Future import scala.concurrent.duration.DurationInt import play.api.mvc.Controller import play.modules.reactivemongo.MongoController import play.api.Logger import play.api.data._ import play.api.data.Forms._ import play.ap...
Explain and rewrite the following Scala code:
package filodb.memory.format.vectors import java.nio.ByteBuffer import debox.Buffer import spire.syntax.cfor._ import filodb.memory.{BinaryRegion, MemFactory} import filodb.memory.format._ import filodb.memory.format.BinaryVector.BinaryVectorPtr import filodb.memory.format.Encodings._ import filodb.memory.format.Mem...
Explain and rewrite the following Scala code:
/* * SPDX-License-Identifier: Apache-2.0 * * Copyright 2015-2021 Andre White. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE...
Explain and rewrite the following Scala code:
/** * 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 com.arcusys.valamis.persistence.impl.scorm.model case class ActivityStateModel(id: Option[Long], packageId: Option[Long], activityId: String, active: Boolean, suspended: Boolean, ...
Explain and rewrite the following Scala code:
package skinny.util import org.scalatest._ class TypesafeConfigReaderSpec extends FunSpec with Matchers { describe("TypesafeConfigReader#load") { it("should read application.conf") { val config = TypesafeConfigReader.load("application.conf") config.getString("name") should equal("bar") confi...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.bulk import com.sksamuel.elastic4s.testkit.{ElasticMatchers, ElasticSugar} import org.scalatest.FlatSpec import org.scalatest.concurrent.Eventually import scala.concurrent.duration._ class BulkTest extends FlatSpec with ElasticSugar with Eventually with ElasticMatchers { override im...
Explain and rewrite the following Scala code:
/* * Copyright 2011-2013 Christos KK Loverdos * * 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 o...
Explain and rewrite the following Scala code:
package json2caseclass.jsonmodels case class Images( startdate: String, fullstartdate: String, enddate: String, url: String, urlbase: String, copyright: String, copyrightlink: String, quiz: String, wp: Boolean, hsh: String, drk: Double, top: Double, bot: Double ) cas...
Explain and rewrite the following Scala code:
package org.bfn.ninetynineprobs import org.scalatest._ class P47Spec extends UnitSpec { // TODO }
Explain and rewrite the following Scala code:
/* * This file is part of Gwaihir * Copyright (C) 2013, 2014 Alvaro Polo * * Gwaihir 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...
Explain and rewrite the following Scala code:
package app.components.semanticui import japgolly.scalajs.react import japgolly.scalajs.react.Children import japgolly.scalajs.react.vdom.VdomNode import scala.scalajs.js object Dimmer { val component = react.JsComponent[js.Object, Children.Varargs, Null](SemanticUiComponents.Dimmer) def apply(active: js.UndefO...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2013 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2012-2013 SnowPlow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
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 vtpassim import org.apache.spark.sql.SparkSession import scala.collection.mutable.StringBuilder import scala.util.Try import scala.xml.pull._ object TCPPages { def main(args: Array[String]) { val spark = SparkSession.builder().appName("TCPPages Import").getOrCreate() import spark.implicits._ s...
Explain and rewrite the following Scala code:
import akka.actor.{ActorRef, ActorSystem, Props} import akka.routing.FromConfig object GuidebookMain extends App { val system: ActorSystem = ActorSystem("BookSystem") val guideProps: Props = Props[Guidebook] val routerProps: Props = FromConfig.props(guideProps) val guidebook: ActorRef = system.actorOf...
Explain and rewrite the following Scala code:
package obj import obj.Material._ class Trash(val n: Int, val material: Material, val name: String) {}
Explain and rewrite the following Scala code:
/* * Copyright (c) 2013-2014 Telefónica Investigación y Desarrollo S.A.U. * * 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 * * Unles...
Explain and rewrite the following Scala code:
package com.sparcedge.turbine.data import scala.collection.mutable import scala.collection.GenMap import com.sparcedge.turbine.query._ import com.sparcedge.turbine.event.Event import com.sparcedge.turbine.util.WrappedTreeMap import com.sparcedge.turbine.Blade object QueryUtil { val GROUP_SEPARATOR = "✈" val GROUP_...
Explain and rewrite the following Scala code:
package com.naokia.groonga4s.util.column import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node._ import org.specs2.mutable.Specification import java.math.BigDecimal class JsonNodeConverterSpec extends Specification{ "JsonNodeConverter" >> { "convert TextNode to String value" ...
Explain and rewrite the following Scala code:
package collins.models.lldp import play.api.libs.json.Format import play.api.libs.json.JsObject import play.api.libs.json.JsSuccess import play.api.libs.json.JsValue import play.api.libs.json.Json object Vlan { implicit object VlanFormat extends Format[Vlan] { override def reads(json: JsValue) = JsSuccess(Vlan(...
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 Language extends Enumeration { val Scala, Java, JavaScript = Value }
Explain and rewrite the following Scala code:
package is.hail.io import java.io.{Closeable, DataOutputStream} import java.util.Arrays import is.hail.utils._ import is.hail.io.fs.FS import scala.collection.mutable object IndexBTree { private[io] def calcDepth(internalAndExternalNodeCount: Long, branchingFactor: Int): Int = { var depth = 1 var maximumT...
Explain and rewrite the following Scala code:
package provingground.learning import provingground.{FiniteDistribution => FD, _} import shapeless._ import monix.eval._ import GeneratorVariables._, Expression._ import scala.concurrent._, duration._ import MonixFiniteDistributionEq._ object MonixFiniteDistributionEq { def finalProb[Y](y: Y, rv: RandomVar[Y])...
Explain and rewrite the following Scala code:
package lila.analyse import lila.game.Pov object Accuracy { private def withSignOf(i: Int, signed: Int) = if (signed < 0) -i else i private val makeDiff: PartialFunction[(Option[Score], Option[Int], Option[Score], Option[Int]), Int] = { case (Some(s1), _, Some(s2), _) => s2.ceiled.centipawns - s1.ceiled.cen...
Explain and rewrite the following Scala code:
/* * Copyright 2014 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 org.shade.common.types object Implicits { implicit class StringDecorator(str: String) { lazy val cleanSafely: Option[CleanString] = { str.trim match { case "" => None case other => Some(CleanString(other)) } } lazy val clean: CleanString = CleanString.of(str) } ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package script import com.intellij.execution.configurations.{ConfigurationFactory, ConfigurationType, RunConfiguration} import com.intellij.openapi.project.Project import org.jetbrains.plugins.scala.project._ /** * User: Alexander Podkhalyuzin * Date: 04.02.2009 */ class Scala...
Explain and rewrite the following Scala code:
// scalac: -Xfatal-warnings // object Test { (Vector(): Seq[_]) match { case List() => true; case Nil => false } }
Explain and rewrite the following Scala code:
package io.udash.utils import scala.scalajs.js object URLEncoder { def encode(query: String, spaceAsPlus: Boolean): String = { val res = js.URIUtils.encodeURIComponent(query) .replace("!", "%21") .replace("'", "%27") .replace("(", "%28") .replace(")", "%29") .replace("~", "%7E") ...
Explain and rewrite the following Scala code:
package com.eevolution.context.dictionary.infrastructure.repository import com.eevolution.context.dictionary.domain.model.WorkflowProcessData import com.eevolution.context.dictionary.infrastructure.db.DbContext._ /** * Copyright (C) 2003-2017, e-Evolution Consultants S.A. , http://www.e-evolution.com * This progr...
Explain and rewrite the following Scala code:
package coursier.cache import java.io.File import java.math.BigInteger import java.nio.file.{Files, Path} import java.security.{KeyStore, MessageDigest} import java.security.cert.X509Certificate import cats.data.NonEmptyList import cats.effect.IO import coursier.core.Authentication import coursier.util.Artifact impor...
Explain and rewrite the following Scala code:
/****************************************************************************** * Copyright (c) 2014, Equal Experts Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of ...
Explain and rewrite the following Scala code:
object Driver { def main(a: Array[String]) { val s = new Solution val n1 = new RandomListNode(1) val n2 = new RandomListNode(2) val n3 = new RandomListNode(3) n1.next = n2 n2.next = n3 n3.random = n1 s.copyRandomList(n1) s.copyRandomList(n2) s.copyRandomList(n3) } }
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.refactoring.extractMethod import _root_.org.jetbrains.plugins.scala.lang.psi.types.ScType import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil import org.jetbrains.plugins.scala.lang.psi.api.statements.params.ScParameter import org.jetbrains.plugins.scala.lang.psi.api.state...
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 metascala.example object HListExample { import metascala.HLists._ import metascala.Nats._ import metascala.Utils._ // Create a HList of an Int, Boolean and a pair val l1 = 10 :: true :: (10.1, "Hello") :: HNil // Extract the second element, note that the element type // information is pres...