instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package endpoints package documented package openapi import endpoints.documented.openapi.model.Info import org.scalatest.{Matchers, OptionValues, WordSpec} class EndpointsTest extends WordSpec with Matchers with OptionValues { "Path parameters" should { "Appear as patterns between braces in the documentation" ...
Explain and rewrite the following Scala code:
package ch.devbox.algorithme import scala.annotation.tailrec object Exercice21 { def fib(n: Int): Int = { @tailrec def f(i: Int, prev: Int, next: Int): Int = i match { case 0 => prev case 1 => next case _ => f(i - 1, next, prev + next) } f(n, 0, 1) } }
Explain and rewrite the following Scala code:
package co.blocke.scalajack package typeadapter package classes import model._ import co.blocke.scala_reflection._ import co.blocke.scala_reflection.info._ import scala.collection.mutable // For case classes and Java/Scala plain classes, but not traits trait ClassTypeAdapterBase[T] extends TypeAdapter[T] with Classi...
Explain and rewrite the following Scala code:
/* * Copyright 2020 ACINQ SAS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in...
Explain and rewrite the following Scala code:
package akka.ainterface.datatype import akka.ainterface.util.binary.ByteStringCodec.byteString import akka.util.ByteString import java.nio.charset.StandardCharsets import scodec.Attempt.{failure, successful} import scodec.bits.{BitVector, ByteVector} import scodec.codecs._ import scodec.{Codec, DecodeResult, Err} impo...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.util import java.io.File import com.intellij.openapi.application.{ApplicationManager, PathManager} import com.intellij.openapi.project.Project import com.intellij.openapi.util.Computable import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiFile import com.intellij...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package impl package statements import com.intellij.lang.ASTNode import com.intellij.psi.PsiElementVisitor import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes._ import org.jetbrains.plugins.scala.lang.psi.api.ScalaElementVisitor import org.jetbr...
Explain and rewrite the following Scala code:
package blunt trait DefaultsTo[Type, Default] /* * This is some typelevel sorcery that allows an implicit * argument to have a default value, which is useful for * making all the operators default to equals. */ object DefaultsTo { implicit def defaultDefaultsTo[T]: DefaultsTo[T, T] = null implicit def fallbac...
Explain and rewrite the following Scala code:
package co.ledger.wallet.core.device.ripple import java.io.ByteArrayInputStream import co.ledger.wallet.core.device.ripple.LedgerCommonApiInterface.CommandResult import co.ledger.wallet.core.utils.{BytesWriter, DerivationPath, HexUtils} import co.ledger.wallet.core.wallet.ripple.RippleAccount import co.ledger.wallet....
Explain and rewrite the following Scala code:
package io.scalac.frees.login.handlers.id import cats.Id import io.scalac.frees.login.algebras.Log class PrintlnLogger extends Log.Handler[Id] { def info(msg: String): Id[Unit] = println(s"[INFO]: $msg") def warn(msg: String): Id[Unit] = println(s"[WARN]: $msg") def warnWithCause(msg: String, cause: ...
Explain and rewrite the following Scala code:
package com.socrata.balboa.impl import java.io.File import com.socrata.balboa.impl.BalboaDispatcherComponentSetup.DispatcherSetup import com.socrata.balboa.metrics.Message import com.socrata.balboa.util.MetricsTestStuff import com.socrata.metrics.components.{EmergencyFileWriterComponent, MessageQueueComponent} import...
Explain and rewrite the following Scala code:
import scala.tools.partest.{ SessionTest, Welcoming } // SI-7740 object Test extends SessionTest with Welcoming { def session = """Welcome to Scala Type in expressions for evaluation. Or try :help. scala> def f = throw new Exception("Uh-oh") f: Nothing scala> f java.lang.Exception: Uh-oh at .f(<console>:11) ....
Explain and rewrite the following Scala code:
/* Lodo is a layered to-do list (Outliner) Copyright (C) 2015 Keith Morrow. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, ...
Explain and rewrite the following Scala code:
package edu.rice.habanero.actors import edu.rice.hj.runtime.actors.Actor /** * * @author <a href="http://shams.web.rice.edu/">Shams Imam</a> (shams@rice.edu) */ abstract class HabaneroActor[MsgType](seqBody: Boolean = true) extends Actor[MsgType](seqBody) { override def process(msg: MsgType): Unit override d...
Explain and rewrite the following Scala code:
package org.fuckboi.ast abstract class OperandNode extends AstNode { }
Explain and rewrite the following Scala code:
{{#public}} package {{package}} import com.twitter.scrooge.{ TFieldBlob, ThriftException, ThriftStruct, ThriftStructCodec3, ThriftUtil} import org.apache.thrift.protocol._ import org.apache.thrift.transport.{TMemoryBuffer, TTransport} import java.nio.ByteBuffer import java.util.Arrays import scala.collection.immutab...
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 2017-19, Emmanouil Antonios Platanios. All Rights Reserved. * * 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 ru.pravo.qa.gatling.remote case class Host(url: String, login: String, password: String, port: Int)
Explain and rewrite the following Scala code:
package models import play.api.db.slick.Config.driver.simple._ import scala.slick.lifted.Tag case class AssesmentQuestionScore(id: Option[Long], assesmentId: Long, scoreId: Long) class AssesmentQuestionScores(tag: Tag) extends Table[AssesmentQuestionScore](tag, "assesments_questions_scores") { def id = column[Lo...
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 rml.args.arg case class Description(text: String) { def /(func: FuncArg[_]) = func -- text def --(func: FuncArg[_]) = /(func) } object / { def /(x: String) = Description(x) }
Explain and rewrite the following Scala code:
package com.criteo.vizatra.vizsql object hsqldb { implicit val dialect = new Dialect { lazy val parser = new SQL99Parser lazy val functions = SQLFunction.standard orElse { case "timestamp" => new SQLFunction2 { def result = { case ((_, t1), (_, t2)) => Right(TIMESTAMP(nullable = t1.nullable || ...
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:
#!/bin/sh exec scala "$0" "$@" !# import scala.io.Source import java.text.SimpleDateFormat import java.io.{PrintWriter, FileWriter, File} import java.util.Date import PowerState.PowerState /** * Power states range from 0 - 4, inclusive. I believe these are related to ACPI * global states, with the states numbers in...
Explain and rewrite the following Scala code:
import scala.collection.mutable._, ArrayBuffer._ class Z { /* */canBuildFrom }
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.hnfmr.chapter11 import cats.Monoid import scala.language.higherKinds trait CRDTCounter[F[_,_], K, V] { def increment(f: F[K, V])(k: K, v: V)(implicit m: Monoid[V]): F[K, V] def merge(f1: F[K, V], f2: F[K, V])(implicit b: BoundedSemiLattice[V]): F[K, V] def total(f: F[K, V])(implicit m: Monoid[V]): ...
Explain and rewrite the following Scala code:
/** * Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0 * See accompanying LICENSE file. */ package kafka.manager import kafka.manager.features.KMLogKafkaFeature import org.apache.curator.framework.recipes.cache._ import org.apache.curator.framework.CuratorFramework import org.joda.time.{Dat...
Explain and rewrite the following Scala code:
package org.broadinstitute.dsde.firecloud.component import org.openqa.selenium.WebDriver case class Label(queryString: QueryString)(implicit webDriver: WebDriver) extends Component(queryString) { def getText: String = readText(query) }
Explain and rewrite the following Scala code:
package com.github.jeffhanson.problem7 object FindNthPrime { /** * Find the Nth prime number in the sequence of primes. Use a stream to generate the * sequence of prime numbers then just use the apply method to access the number * by index. */ def findPrimeByIndex( x: Int ): Int = { def sieve(s: S...
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 controllers import java.util.UUID import javax.inject.Inject import com.mohiva.play.silhouette.api._ import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository import com.mohiva.play.silhouette.api.util.{ PasswordHasherRegistry, PasswordInfo } import com.mohiva.play.silhouette.impl.providers.Creden...
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 2016 Coursera 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 de.htwg.zeta.server.model.modelValidator.validator.rules import de.htwg.zeta.common.models.project.instance.elements.EdgeInstance import de.htwg.zeta.server.model.modelValidator.validator.ModelValidationResult /** * This file was created by Tobias Droth as part of his master thesis at HTWG Konstanz (03/2017 ...
Explain and rewrite the following Scala code:
package example.sparksql import example.ExampleUtils._ /** * @author xiafan */ class sqlexample { def createTables(): Unit = { val sc = getSparkContext() // sc is an existing SparkContext. val sqlContext = new org.apache.spark.sql.SQLContext(sc) // this is used to implicitly convert an RDD to a Da...
Explain and rewrite the following Scala code:
package mimir.ctables; import mimir.algebra._ object CTBounds { /** * Returns two expressions for computing the lower and upper bounds * (respectively) for a given expression. * * - For numeric values, the upper and lower bounds are defined intuitively. * - For boolean values, False < True. T...
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 Intel Corporation under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * Intel Corporation licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use t...
Explain and rewrite the following Scala code:
/** * Created by Psycho7 on 10/5/16. */ object Arithmetic { class S99Int(val start: Int) { import S99Int._ // P31 def isPrime: Boolean = (start > 1) && (2 to Math.sqrt(start).toInt).forall { start % _ != 0 } // P33 def isCoprimeTo(that: S99Int): Boolean = gcd(this, that...
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:
import scala.io.Source import scala.sys.process._ import java.io._ case class Config(name: String, repo: String) val samples = List( Config("name","repo.git")) samples foreach { c => print(c.name + " ") println(Source.fromFile(s"/home/chisun/clone/trend_output/${c.name}/trend.txt").getLines.toList.la...
Explain and rewrite the following Scala code:
package app import service._ import util.AdminAuthenticator import util.StringUtil._ import util.ControlUtil._ import util.Directory._ import util.Implicits._ import jp.sf.amateras.scalatra.forms._ import org.scalatra.i18n.Messages import org.apache.commons.io.FileUtils class UserManagementController extends UserMana...
Explain and rewrite the following Scala code:
// basically just copy paste, except for specialization /* * Scala (https://www.scala-lang.org) * * Copyright EPFL and Lightbend, Inc. * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). * * See the NOTICE file distributed with this work for * additional information regarding ...
Explain and rewrite the following Scala code:
package models import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import spray.json.DefaultJsonProtocol object AddressResult extends SprayJsonSupport with DefaultJsonProtocol { implicit val addressResultFormat = jsonFormat4(AddressResult.apply) } case class AddressResult ( originalQuery: String, ...
Explain and rewrite the following Scala code:
package com.allaboutscala.learn.spark.functions import com.allaboutscala.learn.spark.utils.Context /** * Created by Nadim Bahadoor on 28/06/2016. * * Tutorial: Learn How To Use Apache Spark * * [[http://allaboutscala.com/big-data/spark/]] * * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com) *...
Explain and rewrite the following Scala code:
package is.hail.types.physical import is.hail.annotations.{CodeOrdering, Region} import is.hail.asm4s.{Code, TypeInfo, Value} import is.hail.expr.ir.{Ascending, Descending, EmitCodeBuilder, EmitMethodBuilder, SortOrder} trait PUnrealizable extends PType { private def unsupported: Nothing = throw new Unsupported...
Explain and rewrite the following Scala code:
import scala.tools.nsc.Settings import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ class Color(val red: Int) case class Red(r:Int) extends Color(r) def f(c: Any) = c match { case Red(_) => () } """ }
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.analyzers import org.scalatest.{Matchers, WordSpec} class LengthTokenFilterTest extends WordSpec with TokenFilterApi with Matchers { "LengthTokenFilter builder" should { "not set defaults" in { lengthTokenFilter("testy").json.string shouldBe """{"type":"length"}""" } ...
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.psi.impl.source.resolve.ResolveCache import com.intellij.util.IncorrectOperationException import lexer.ScalaTokenTypes import psi.ScalaPsiElementImpl import api.base.types._ import psi.types._ impor...
Explain and rewrite the following Scala code:
package controllers import com.google.inject.Singleton import play.api.mvc._ @Singleton class Application extends Controller { def index = Action { Ok(views.html.index()) } }
Explain and rewrite the following Scala code:
package latis.dm import latis.data.Data import latis.data.EmptyData import latis.metadata.Metadata import latis.metadata.EmptyMetadata import latis.ops.Projection import latis.ops.filter.FirstFilter import latis.ops.filter.LastFilter import latis.ops.filter.Selection import latis.ops.math.BasicMath import latis.util.D...
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:
// Copyright (C) 2011 - Will Glozer. All rights reserved. package com.lambdaworks.jacks import com.fasterxml.jackson.annotation.JsonInclude.Include._ import com.fasterxml.jackson.core._ import com.fasterxml.jackson.core.JsonToken._ import com.fasterxml.jackson.databind._ import com.fasterxml.jackson.databind.ser.std...
Explain and rewrite the following Scala code:
package dotty.tools.dotc.util import reflect.ClassTag object Util { /** The index `i` in `candidates.indices` such that `candidates(i) <= x` and * `candidates(i)` is closest to `x`, determined by binary search, or -1 * if `x < candidates(0)`. * @param hint If between 0 and `candidates.length` use t...
Explain and rewrite the following Scala code:
package debop4s.core import java.util.concurrent.atomic.AtomicBoolean import org.slf4j.LoggerFactory /** * JDK 7 의 try λ¦¬μ†ŒμŠ€ 정리 μž‘μ—…μ„ μˆ˜ν–‰ν•  수 μžˆλ„λ‘ ν•΄μ£ΌλŠ” ν΄λž˜μŠ€μž…λ‹ˆλ‹€. * * @author λ°°μ„±ν˜ sunghyouk.bae@gmail.com * @since 2013. 12. 10. μ˜€ν›„ 1:57 */ class AutoCloseableAction(val closingAction: Runnable) extends AutoCloseable { def ...
Explain and rewrite the following Scala code:
/** * (c) Copyright 2013 WibiData, Inc. * * See the NOTICE 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. * You may obtain a copy of...
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:
/* * sbt * Copyright 2011 - 2018, Lightbend, Inc. * Copyright 2008 - 2010, Mark Harrah * Licensed under Apache License 2.0 (see LICENSE) */ import sbt._ import org.scalacheck._ import Prop._ import TaskGen._ object TaskRunnerCallTest extends Properties("TaskRunner Call") { property("calculates fibonacci") = f...
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 2013 websudos ltd. * * 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 org.scalawebtest.aem import java.net.URI import org.scalawebtest.core.IntegrationSpec import play.api.libs.json.{JsObject, JsValue, Json} import scala.util.Try /** * The PageProperties trait populates the pageProperties, and if applicable componentProperties and suffixProperties fields with a JsValue * ...
Explain and rewrite the following Scala code:
import blah.* object Test { def main(args: Array[String]): Unit = { A.f A.B.f A.B.C.f } }
Explain and rewrite the following Scala code:
package com.codacy.client.stash.helpers import java.io.ByteArrayOutputStream import com.jcraft.jsch._ object SSHKeyGenerator { def generateKey(keyType: Int = KeyPair.RSA, size: Int = 4096): (String, String) = { val keyPair = KeyPair.genKeyPair(new JSch(), keyType, size) val publicStream = new ByteArr...
Explain and rewrite the following Scala code:
/** * Copyright (c) 2014, MoonGene. All rights reserved. * * This source code is licensed under the GPL license found in the * LICENSE_GPL file in the root directory of this source tree. An alternative * commercial license is also available upon request. */ package com.moongene import com.typesafe.config.Config...
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 fi.proweb.train.actor.component import akka.actor.Actor import akka.actor.ActorRef import akka.actor.ActorLogging import fi.proweb.train.model.AppData abstract class DataFormatter[T <: AppData[T]] extends Actor with ActorLogging { var deliveryTarget: Option[ActorRef] = None def receive = { case ...
Explain and rewrite the following Scala code:
package fr.univ.nantes.roomanager class Batiment(var no_bat: Int, var nom: String, var adresse: Adresse) { var salles: Set[Salle] = Set() }
Explain and rewrite the following Scala code:
package polyite.schedule.schedule_tree.util import polyite.schedule.ScheduleUtils.CmpMultiResult import isl.Isl import isl.Isl.TypeAliases._ import isl.Conversions._ import polyite.schedule.schedule_tree.ScheduleNode import isl.ScheduleNodeType._ import polyite.schedule.Dependence import polyite.schedule.schedule_tree...
Explain and rewrite the following Scala code:
package warsztat import java.time.{LocalDate, LocalDateTime} import java.util.UUID import org.scalatest.{EitherValues, FlatSpec, Matchers} class LogParserTest extends FlatSpec with Matchers with EitherValues { import LogConverters._ it should "parse event record " in { val uuid = UUID.randomUUID() val ...
Explain and rewrite the following Scala code:
package akka.persistence.jdbc.migrator import akka.actor.{ ActorRef, ActorSystem, Props, Stash } import akka.event.LoggingReceive import akka.pattern.ask import akka.persistence.jdbc.SimpleSpec import akka.persistence.jdbc.config.{ JournalConfig, SlickConfiguration } import akka.persistence.jdbc.db.SlickDatabase impor...
Explain and rewrite the following Scala code:
package basinet class Chain[SR <: Source[SR, T], SN <: Sink[SN, U], T, U] (source: Source[SR, T], sink: Sink[SN, U], wire: Wire[SR, SN], set: evil_ant.MultiSignalSet) extends Channel { self => override def isOpen = source.isOpen || sink.isOpen override def _close { if(source.isOpen) source.close i...
Explain and rewrite the following Scala code:
package com.stratio.ioft /* This packages contains entity objects representing abstract concepts related to drone state within the real world as well as value types used to represent measures. */ package object domain { type DroneIdType = String type TimestampMS = BigInt }
Explain and rewrite the following Scala code:
package com.example.api.controllers import org.scalatestplus.play.{ OneAppPerSuite, PlaySpec } import play.api.http.MimeTypes.TEXT import play.api.test.FakeRequest import play.api.test.Helpers._ class HealthCheckIntegrationSpec extends PlaySpec with OneAppPerSuite { "#index" should { "return OK" in { val...
Explain and rewrite the following Scala code:
package caustic.compiler.gen import caustic.grammar._ /** * Generates a formatted Scala comment from a comment. Caustic supports both C-style comments (/**/) * and C++-style comments (//). Left aligns comment strings. */ object GenComment extends CausticBaseVisitor[String] { override def visitComment(ctx: Caust...
Explain and rewrite the following Scala code:
package com.colingodsey.logos.collections trait MapVectorCompanion[+T >: MapVector <: Vec] extends VecCompanion[T] { val origin: T = MapVector() def apply(x: Vec): T = MapVector(x.toVecN.weights.toSeq: _*) def apply(weightSeq: (String, Double)*): T = MapVector(weightSeq.toMap) def apply(weights: Map[String, Dou...
Explain and rewrite the following Scala code:
package ${package} /** * 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 (th...
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 java.text.SimpleDateFormat import endpoints._ import models._ import org.json4s._ import org.json4s.jackson.JsonMethods._ /** * SpotifyClient is the main class used to interact with the Spotify API's. * * If the return type of a method is wrapped in an Option, this means that the method * requires an ...
Explain and rewrite the following Scala code:
package net.sansa_stack.query.spark.graph.jena.util import net.sansa_stack.query.spark.graph.jena.util.NodeType.NodeType import org.apache.jena.graph._ import org.apache.spark.graphx.{EdgeTriplet, VertexId} class MatchCandidate( val target: EdgeTriplet[Node, Node], val pattern: TriplePattern, nodeType: NodeType...
Explain and rewrite the following Scala code:
package com.twitter.hashing import org.specs.mock.Mockito import org.specs.SpecificationWithJUnit import scala.collection.mutable import _root_.java.io.{BufferedReader, InputStreamReader} class KetamaDistributorSpec extends SpecificationWithJUnit with Mockito { "KetamaDistributor" should { val nodes = Seq( ...
Explain and rewrite the following Scala code:
package com.github.tminglei.slickpg package geom import slick.lifted._ import slick.ast.{LiteralNode, TypedType} import slick.ast.Library.{SqlFunction, SqlOperator} import slick.lifted.FunctionSymbolExtensionMethods._ import slick.jdbc.{JdbcType, JdbcTypesComponent, PostgresProfile} trait PgPostGISExtensions extends ...
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 fafa.api import fafa.api.Board._ import fafa.api.Role.{Queen, Knight} /** * Created by mac on 04.01.16. */ class QueenTest extends ChessApiTest { "Queen" should "threat pieces at the same rank, file or diagonal" in { val actor = """ | | | |p |p p ...
Explain and rewrite the following Scala code:
package com.example //class MyServiceSpec extends Specification with Specs2RouteTest with MyService { // def actorRefFactory = system // // "MyService" should { // // "return a greeting for GET requests to the root path" in { // Get() ~> myRoute ~> check { // responseAs[String] must contain("Say hello...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* Copyright (C) 2012-2013 Treode, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
package com.twitter.querulous.evaluator import com.twitter.querulous._ import java.sql.ResultSet import concurrent.duration._ import com.twitter.querulous.database._ import com.twitter.querulous.query._ object QueryEvaluator extends QueryEvaluatorFactory { private def createEvaluatorFactory() = { val queryFact...
Explain and rewrite the following Scala code:
package dataAnalysis import org.apache.spark.SparkConf import org.apache.spark.SparkContext import org.apache.spark.ml.classification.{LogisticRegression, LogisticRegressionModel} import org.apache.spark.ml.feature.VectorAssembler import org.apache.spark.ml.param.Param import org.apache.spark.rdd.RDD import org.apache...
Explain and rewrite the following Scala code:
package com.twitter.inject.thrift.integration.serviceperendpoint import com.twitter.finagle.Service import com.twitter.inject.thrift.integration.AbstractThriftService import com.twitter.test.thriftscala.EchoService import com.twitter.test.thriftscala.EchoService.Echo import com.twitter.test.thriftscala.EchoService.Set...
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.michaelhamrah.flickrgpx import scala.Array.canBuildFrom import com.github.nscala_time.time.Imports.DateTime import com.github.nscala_time.time.Imports.DateTimeZone import com.github.nscala_time.time.Imports.Duration import com.michaelhamrah.flickrgpx.FlickrUpdater.searchByDay import com.michaelhamrah.flic...
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 scalaz.stream.mongodb.aggregate import com.mongodb.{BasicDBObject, DBObject, DBCollection} import scalaz.stream.mongodb.channel.ChannelResult import scalaz.stream.Process import scalaz.stream.Process._ import scalaz.concurrent.Task import scalaz.stream.mongodb.query.Query import collection.JavaConverters._ t...
Explain and rewrite the following Scala code:
package com.todesking.nyandoc sealed abstract class Markup object Markup { // Paragraph/Block case class Heading(contents:Seq[Markup]) extends Markup case class Paragraph(children:Seq[Markup]) extends Markup case class Code(content:String, language:String) extends Markup case class HorizontalLine() extends ...
Explain and rewrite the following Scala code:
package streams import java.text.SimpleDateFormat import org.jfree.chart.JFreeChart import org.jfree.chart.axis.{DateAxis, NumberAxis} import org.jfree.chart.plot.XYPlot import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer import org.jfree.data.time.{TimeSeries, TimeSeriesCollection} object StreamingChart { d...
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:
/* * 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 ...