instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
// TxBits - An open source Bitcoin and crypto currency exchange // Copyright (C) 2014-2015 Viktor Stanchev & Kirk Zathey // // 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 vers...
Explain and rewrite the following Scala code:
import org.specs2.mutable._ import org.specs2.runner._ import org.junit.runner._ import play.api.test._ import play.api.test.Helpers._ @RunWith(classOf[JUnitRunner]) class IntegrationSpec extends Specification { sequential "Application" should { "send 404 on a bad request" in new WithApplication { ...
Explain and rewrite the following Scala code:
package adt.bson.mongo import adt.bson.{BsonValue, BsonObject} import com.mongodb.ErrorCategory import scala.language.implicitConversions trait JavaCoreDriverModels { type JavaWriteError = com.mongodb.WriteError type JavaWriteConcernResult = com.mongodb.WriteConcernResult } /** * Represents an error fo...
Explain and rewrite the following Scala code:
package play.json.extra import java.time.LocalDateTime import org.scalatest.FunSuite import play.api.libs.json.Json class LocalDatetimeTests extends FunSuite { final case class TestDataTime(dt:LocalDateTime) implicit val jsonFmt=Json.format[TestDataTime] test("basic LocalDateTime test") { val dt = LocalD...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2020 by The Monix Project Developers. * See the project homepage at: https://monix.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache...
Explain and rewrite the following Scala code:
package com.programmaticallyspeaking.ncd.nashorn.java9 import com.programmaticallyspeaking.ncd.host.{StepInto, StepOver} import com.programmaticallyspeaking.ncd.nashorn.StepTestFixture class StepTest extends StepTestFixture with RunningJava9 { "Stepping for Java 9" - { "into" - { "enters a function" in {...
Explain and rewrite the following Scala code:
package ingraph.sandbox import ingraph.compiler.CypherToGPlan import ingraph.compiler.cypher2gplan.CypherParser import org.scalatest.FunSuite class TrainBenchmarkDmlTest extends FunSuite { ignore("ConnectedSegment Inject") { parse( """MATCH | (sensor {id: $sensor}), | (segment1 {id: $se...
Explain and rewrite the following Scala code:
package stream.rate import akka.actor.ActorSystem import akka.stream.scaladsl.Flow import scala.concurrent.duration.FiniteDuration trait FlowGraphs { def constantDelay[T](delay: FiniteDuration)(implicit system: ActorSystem) = Flow[T].transform(() => DelayStage[T](Iterator.continually(delay))) def constantR...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2009-2011 the original author or authors. * See the notice.md 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 arx.core.graphics.data /** * Created by IntelliJ IDEA. * User: nvt * Date: 4/9/12 * Time: 11:29 AM * Created by nonvirtualthunk */ import arx.core.vec._ import org.lwjgl.opengl.GL15 trait TVBOLike { def unsolidify () def clear () } trait TVBO extends TVBOLike { def writingActive : Boolean def writ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.completion import com.intellij.codeInsight.completion.{CompletionParameters, CompletionConfidence} import com.intellij.util.ThreeState import com.intellij.psi.{PsiFile, PsiElement} import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes import com.intellij.psi.tree.IEleme...
Explain and rewrite the following Scala code:
package com.karlkyck.leetcode.algorithms.combinationsum /** * Created by karlkyck on 23/07/17. */ object Solution { def twoSum(nums: Array[Int], target: Int): Array[Int] = { val numsMap = nums.zipWithIndex.map { case (num, index) => num -> index }.toMap nums.zipWithIndex.foldLeft(Array[Int]()) { ...
Explain and rewrite the following Scala code:
package euler package til30 object Euler26 extends EulerProblem { def decimals(n: Int, d: Int): Stream[(Int, Int)] = { if (n == 0) Stream.empty else ((n % d * 10 / d), n % d) #:: decimals(n % d * 10, d) } def repeatingDecimals(n: Int, d: Int): List[Int] = { var remainders: List[Int] = Nil var re...
Explain and rewrite the following Scala code:
package org.gbougeard.model.changes /** * Created with IntelliJ IDEA. * User: gbougeard * Date: 13/07/13 * Time: 20:42 * To change this template use File | Settings | File Templates. */ case class AbandonInput(message: Option[String]) object AbandonInput { import play.api.libs.json.Json import play.api.lib...
Explain and rewrite the following Scala code:
package io.getquill.codegen import java.sql.DriverManager import io.getquill.codegen.jdbc.gen.JdbcGeneratorBase import io.getquill.codegen.jdbc.model.JdbcTypes.JdbcQuerySchemaNaming import io.getquill.codegen.model.Stereotyper.Namespacer import io.getquill.codegen.model._ import io.getquill.codegen.util.SchemaConfig ...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2002-2018 "Neo Technology," * Network Engine for Objects in Lund AB [http://neotechnology.com] * * This file is part of Neo4j. * * Neo4j 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 Foundatio...
Explain and rewrite the following Scala code:
package algebra.ring import algebra.instances.bigInt._ import org.scalacheck.Prop._ class RingTest extends munit.DisciplineSuite { test("Ring.defaultFromBigInt") { forAll { (n: BigInt) => assertEquals(Ring.defaultFromBigInt[BigInt](n), n) } } }
Explain and rewrite the following Scala code:
package scala.tasty.internal import scala.tools.nsc.Global import scala.tasty.internal.dotc.ast.TTrees import scala.tasty.internal.dotc.core._ import scala.tasty.internal.dotc.core.tasty._ import scala.tasty.internal.convert._ class API(val global: Global) extends TTrees with Signatures ...
Explain and rewrite the following Scala code:
package com.estus.optimization import java.io.ByteArrayOutputStream import com.esotericsoftware.kryo.io.Input import org.apache.hadoop.io.{Text, BytesWritable} import org.apache.spark.SparkContext import org.apache.spark.rdd.RDD import org.apache.spark.serializer.KryoSerializer trait JournalTrait { // Accessors ...
Explain and rewrite the following Scala code:
package websocket4s.core /** * Created by namnguyen on 5/23/15. */ case class Request(id:String ,data:String ,senderId:Option[String] ,receiverId:Option[String] ,forTags:Option[Set[String]] )
Explain and rewrite the following Scala code:
/* * Accio is a platform to launch computer science experiments. * Copyright (C) 2016-2018 Vincent Primault <v.primault@ucl.ac.uk> * * Accio 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...
Explain and rewrite the following Scala code:
// // HaltException.scala -- Scala exception HaltException // Project OrcScala // // Created by amp in 2016. // // Copyright (c) 2017 The University of Texas at Austin. All rights reserved. // // Use and redistribution of this file is governed by the license terms in // the LICENSE file found in the project's top-level...
Explain and rewrite the following Scala code:
package uk.gov.gds.ier.test import uk.gov.gds.ier.guice.WithConfig import uk.gov.gds.ier.config.Config import org.scalatest.mock.MockitoSugar trait WithMockConfig extends WithConfig { private val mockito = new MockitoSugar {} val config = mockito.mock[Config] }
Explain and rewrite the following Scala code:
// // Sites.scala -- Scala traits ValueMetadata and HasMembersMetadata // Project OrcScala // // Created by dkitchin on Aug, 2018. // // Copyright (c) 2018 The University of Texas at Austin. All rights reserved. // // Use and redistribution of this file is governed by the license terms in // the LICENSE file found in t...
Explain and rewrite the following Scala code:
package org.scaladebugger.api.profiles.java.info.events import com.sun.jdi.event._ import com.sun.jdi.{Location, ReferenceType, ThreadReference, VirtualMachine} import org.scaladebugger.api.lowlevel.JDIArgument import org.scaladebugger.api.lowlevel.events.JDIEventArgument import org.scaladebugger.api.lowlevel.requests...
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 scala.meta package tokens import org.scalameta.adt.{Liftables => AdtLiftables} import scala.meta.internal.tokens._ import scala.meta.inputs._ import scala.meta.classifiers._ import scala.meta.dialects.Metalevel import scala.meta.prettyprinters._ import scala.meta.internal.prettyprinters._ // NOTE: `start` and...
Explain and rewrite the following Scala code:
package com.ponkotuy.tool import java.io.{Closeable, File} import java.nio.file.Files /** * * @author ponkotuy * Date: 14/03/23. */ object TempFileTool { private val Fname = "tempfiletool_myfleet" def save[T](dat: Array[Byte], extension: String)(f: File => T): T = { val temp = Files.createTempFile(Fname,...
Explain and rewrite the following Scala code:
package transport.play import scala.scalajs.js import transport._ object PlayUtils { /** Load the SockJSUrl defined in a play template. */ def sockJSFromPlayRoute(): SockJSUrl = { try { SockJSUrl(js.Dynamic.global.sockJSUrl.asInstanceOf[String]) } catch { case e: ClassCastException => // Or Un...
Explain and rewrite the following Scala code:
/** * Copyright (c) 2013-2015 Patrick Nicolas - Scala for Machine Learning - All rights reserved * * The source code in this file is provided by the author for the sole purpose of illustrating the * concepts and algorithms presented in "Scala for Machine Learning". It should not be used to * build commercial ap...
Explain and rewrite the following Scala code:
package com.airtonjal.poc.utils import java.io.{FileFilter, File} import org.apache.commons.io.filefilter.WildcardFileFilter import org.apache.commons.logging.LogFactory /** * Utilities object to parse command line arguments * @author <a href="mailto:airtonjal@gmail.com">Airton Libório</a> */ object CommandLineUt...
Explain and rewrite the following Scala code:
/* * The MIT License * * Copyright (c) 2017 Nils Homer * * 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 use, copy, m...
Explain and rewrite the following Scala code:
package de.sciss.fscape.tests import de.sciss.file._ import de.sciss.fscape.{Graph, graph, stream} import scala.Predef.{any2stringadd => _} // issue #24 object AffineTest3 { def main(args: Array[String]): Unit = run() def run(): Unit = { val startFrame = 3 val endFrame = 139 val numFrames = en...
Explain and rewrite the following Scala code:
// timber -- Copyright 2012-2021 -- Justin Patterson // // 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 l...
Explain and rewrite the following Scala code:
/* __ *\\ ** ________ ___ / / ___ __ ____ Scala.js Test Suite ** ** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL ** ** __\\ \\/ /__/ __ |/ /__/ __ |/_// /_\\ \\ http://scala-js.org/ ** ** /____/\\___/...
Explain and rewrite the following Scala code:
package modules import com.google.inject.name.Named import com.google.inject.{ AbstractModule, Provides } import com.mohiva.play.silhouette.api.actions.{ SecuredErrorHandler, UnsecuredErrorHandler } import com.mohiva.play.silhouette.api.crypto._ import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository imp...
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:
/* * 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-2.0 * ...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2017 SnappyData, Inc. 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 required by ap...
Explain and rewrite the following Scala code:
package actors import akka.actor.{Actor, ActorLogging, ActorSystem} import lib.Pager import com.bryzek.apidoc.api.v0.models.{GeneratorForm, GeneratorService} import com.bryzek.apidoc.generator.v0.Client import com.bryzek.apidoc.generator.v0.models.Generator import db.{Authorization, UsersDao} import db.generators.{Gen...
Explain and rewrite the following Scala code:
object Test extends AnyRef with App { val x = 1; def try1 = { Console.print("1 + 1 = "); Console.println(1 + ( try { x; } catch { case _: Error => 1; } )); } def try2 = { Console.print("1 + 1 = "); Console.println( (try { x } catch { case _: ...
Explain and rewrite the following Scala code:
package org.mccandless.minotaur.types /** * A type in the lambda calculus. */ sealed trait Type { } case class ValType(name: String) extends Type case class FunctionType(domain: Type, codomain: Type) extends Type { override def toString: String = s"(${this.domain} => ${this.codomain})" }
Explain and rewrite the following Scala code:
package net.sansa_stack.owl.flink import org.apache.flink.api.scala.DataSet import org.semanticweb.owlapi.model.OWLAxiom package object dataset { type OWLExpressionsDataSet = DataSet[String] type OWLAxiomsDataSet = DataSet[OWLAxiom] }
Explain and rewrite the following Scala code:
package controllers import views.html.helper.FieldConstructor import views.html.helper.twitterBootstrapFieldConstructor object BootstrapHelper { implicit val fields = FieldConstructor(twitterBootstrapFieldConstructor.f) }
Explain and rewrite the following Scala code:
package org.rz.akkagraphite.model.data import org.rz.akkagraphite.actors.Messages.EXCEPTION_UNPARSEABLE_GRAPHITE_PLAIN_TEXT import scala.util.matching.Regex /** * Graphite plaint text data protocol. * * @author rozasdev (rozasdev at gmail.com) * @see http://graphite.readthedocs.org/en/latest/feeding-carbon.h...
Explain and rewrite the following Scala code:
/* * Copyright 2010 LinkedIn * * 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:
import scala.compiletime.testing._ object Test { trait Eq[T] implicit val eq: Eq[Int] = new Eq[Int] {} implicit class AnyOps[T](x: T) { def === (y: T)(implicit c: Eq[T]) = x == y } def main(args: Array[String]): Unit = { assert(typeChecks("5 === 5")) assert(!typeChecks("5.6 === 7.7")) val...
Explain and rewrite the following Scala code:
/* Minimized from collection strawman This issue has a lot to do with both mixin and bridge generation and subtleties in JVM spec if something breaks in this test, this is not a minor issue. Be careful. Here be dragons. */ trait Define[A] { protected def coll: Define[A] def s = coll } trait Iterable[A] 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 ...
Explain and rewrite the following Scala code:
package org.http4s import cats.{Order, Show} import org.http4s.internal.parboiled2.{Parser => PbParser} import org.http4s.parser.{AdditionalRules, Http4sParser} import org.http4s.util.Writer import scala.reflect.macros.whitebox /** * A Quality Value. Represented as thousandths for an exact representation rounded t...
Explain and rewrite the following Scala code:
// package benchmarks // package matrix // package syntax // import org.scalacheck._ // import org.scalacheck.Prop._ // import cilib._ // import shapeless._ // import spire.math.Interval // import spire.implicits._ // import benchmarks.implicits._ // import Generators._ // object MatrixSyntaxTests extends Propertie...
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 dotty.tools package dotc package ast import core._ import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._ import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._ import Decorators._ import language.higherKinds import collection.mutable.ListBuffer import config.Pri...
Explain and rewrite the following Scala code:
package sample.lib import net.liftweb.http.rest.RestHelper object BookshopHttpServiceBasic extends RestHelper { serve { case "bookshop" :: "books" :: Nil XmlGet _ => response(Bookshop.stock) case "bookshop" :: "books" :: publisher :: Nil XmlGet _ => response(Bookshop.stock.filter(_.publisher e...
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:
package com.flowy.fomoapi.database.postgres.schema import java.time.OffsetDateTime import java.util.UUID import com.flowy.common.utils.sql.SqlDatabase import com.flowy.common.models.{User, UserData} /** * TODO: deprecate this class and move all references to common SqlUserSchema * The schemas are in separate tr...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2010 Lalit Pant <pant.lalit@gmail.com> * * The contents of this file are subject to the GNU General Public License * Version 3 (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.gnu.org/copyleft/gpl.html * *...
Explain and rewrite the following Scala code:
package dao import javax.inject._ /** * Simplifies access to all available Dao implementations so that they don't have to * be injected one by one and therefore, reduces the otherwise injection cluttering. * @param linkedAccountDao * @param securityRoleDao * @param tokenActionDao * @param userDao * @par...
Explain and rewrite the following Scala code:
// *** DO NOT EDIT *** This is a C'Dent generated Scala module. /** * This is World class :) */ class World { def greet() { println("Hello, world") } }
Explain and rewrite the following Scala code:
package br.ufmg.cs.lib.dmining.fim.pfp // log import org.apache.log4j.Level import org.apache.log4j.Logger // spark import org.apache.spark.broadcast.Broadcast import org.apache.spark.Partitioner import org.apache.spark.SparkConf import org.apache.spark.SparkContext._ import org.apache.spark.storage.StorageLevel impo...
Explain and rewrite the following Scala code:
package org.jetbrains.sbt package project package data package service import java.io.File import java.net.URI import com.intellij.openapi.externalSystem.model.DataNode import com.intellij.openapi.externalSystem.model.project.ProjectData import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.uti...
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 agreed to in writ...
Explain and rewrite the following Scala code:
package chee.sbt import org.stringtemplate.v4._ import org.stringtemplate.v4.misc._ import scala.util.{ Try, Success, Failure } /** Helper for stringtemplate */ trait Template { type Context = Map[String, Any] def render(context: Context): String def write(file: sbt.File, context: Context): Int } object Templ...
Explain and rewrite the following Scala code:
/* * Copyright (C) Lightbend Inc. <https://www.lightbend.com> */ package docs.home.scaladsl.persistence import scala.collection.immutable import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry import com.lightbend.lagom.scaladsl.playjson.JsonSerializer object BlogPostSerializerRegistry extends JsonSe...
Explain and rewrite the following Scala code:
object ch10_4 { import ch10._ import lib_gen._ import Prop._ def three[A](x: Gen[A]) = for { a <- x b <- x c <- x } yield (a, b, c) def monoidLaws[A](m: Monoid[A], gen: Gen[A]): Prop = { val associativity: Prop = forAll(three(gen))(x => m.op(x._1, m.op(x._2, x._3)) == m.op(m.op(x._1...
Explain and rewrite the following Scala code:
package com.goyeau.kubernetes.client.operation import cats.effect._ import cats.implicits._ import com.goyeau.kubernetes.client.api.NamespacesApiTest import com.goyeau.kubernetes.client.{KubeConfig, KubernetesClient} import munit.Suite import org.typelevel.log4cats.Logger import java.io.File trait MinikubeClientProv...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2015 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:
package com.codility.challenge._2_Arrays /** * Created by obarros on 28/10/2016. */ object OddOccurrencesInArray { def solution(a: Array[Int]): Int = { // sorte the array and find the element unpaired if(a.length == 1) return a(0) val aSorted = a.sorted def loop(array: Array[Int], index: Int): ...
Explain and rewrite the following Scala code:
package magic.gol.routes import spray.routing._ import akka.actor.Props import magic.gol.services.TeamService trait TeamRoute extends HttpService { val teamService = actorRefFactory.actorOf(Props[TeamService], "team-service") def teamRoute = path("team" / Segment ) { team => get { complete(team) }...
Explain and rewrite the following Scala code:
package ohnosequences.tabula.test import ohnosequences.tabula._, resources._, tables._ object ResourceLists { import simpleModel._ type TT = AnyTable :+: AnyTable :+: RNil val uh: TT = UsersTable :+: RandomTable :+: RNil trait AnyAction { type Resources <: ResourceList } trait AnyJoinTables extend...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not u...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Matt Massie * * 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.mux import com.twitter.app.GlobalFlag import com.twitter.conversions.time._ import com.twitter.finagle._ import com.twitter.finagle.context.{Contexts, RemoteInfo} import com.twitter.finagle.mux.lease.exp.{Lessee, Lessor, nackOnExpiredLease} import com.twitter.finagle.mux.transport.Message i...
Explain and rewrite the following Scala code:
object O { class C } def f(p: O) import /* resolved: false */ v.C println(classOf[/* resolved: false */ C])
Explain and rewrite the following Scala code:
package scala import logging.slf4j.HelloWorld object HelloWorldTest { def main(args: Array[String]): Unit = { val VALID_GRADES = Set("A", "B", "C", "D", "F") def letterGrade(value: Any): String = value match { case x: Int if (90 to 100).contains(x) => "A" case x: Int if (80 to 90).contains(x)...
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:
/** * This file is part of mycollab-web. * * mycollab-web 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. * * mycollab-web is d...
Explain and rewrite the following Scala code:
package mgoeminne.scalaggplot.geom import mgoeminne.scalaggplot.position.Position import mgoeminne.scalaggplot.stat.Statistic import mgoeminne.scalaggplot.{position, stat, aes} import org.saddle.Frame /** * Ribbons, y range with continuous x values. * * == Aesthetics * * This function understands the following ...
Explain and rewrite the following Scala code:
/* * Copyright 2015 the original author or authors. * @https://github.com/scouter-project/scouter * * 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/...
Explain and rewrite the following Scala code:
import sbt._ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ object Settings { val name = "pairing-buddy" val version = "0.1.0" val scalacOptions = Seq( "-Xlint", "-unchecked", "-deprecation", "-feature" ) object v { val scala = "2.12.1" val scalaDom = "0.9...
Explain and rewrite the following Scala code:
package org.phenoscape.scowl import org.semanticweb.owlapi.apibinding.OWLManager import org.semanticweb.owlapi.vocab.OWL2Datatype trait Vocab { private val factory = OWLManager.getOWLDataFactory val XSDInteger = factory.getIntegerOWLDatatype val XSDFloat = factory.getFloatOWLDatatype val XSDDouble = facto...
Explain and rewrite the following Scala code:
/* * Copyright 2013 - 2015, Daniel Krzywicki <daniel.krzywicki@agh.edu.pl> * * 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 ...
Explain and rewrite the following Scala code:
package controllers.backend import com.github.tminglei.slickpg.InetString import java.util.{Date,UUID} import java.sql.Timestamp import models.{Session=>OSession,User} // beware database.Slick.simple.Session import models.tables.{Sessions,Users} class DbSessionBackendSpec extends DbBackendSpecification { trait Bas...
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.geishatokyo.sqlgen.core.impl import com.geishatokyo.sqlgen.core.DataType /** * Created by takezoux2 on 2017/06/14. */ class ColumnTypeGuesser { def fromName(name: String): DataType = { if(longable.check(name)) DataType.Integer else if(timeable.check(name)) DataType.Date else DefaultType...
Explain and rewrite the following Scala code:
package org.denigma.nlp.extractions import java.nio.ByteBuffer import akka.actor.{Actor, ActorLogging, ActorRef} import better.files.File import com.typesafe.config.Config import edu.arizona.sista.processors.Document import edu.arizona.sista.reach.mentions.BioMention import net.ceedubs.ficus.Ficus._ import org.denigm...
Explain and rewrite the following Scala code:
package net.fwbrasil.zoot.core.endpoint import net.fwbrasil.zoot.core.request.Request import net.fwbrasil.zoot.core.request.RequestPath import net.fwbrasil.zoot.core.request.RequestPathTemplate case class EndpointTemplate private[EndpointTemplate] ( method: String, path: RequestPathTemplate) { def tryParse(r...
Explain and rewrite the following Scala code:
package io.buoyant.namerd.iface import com.twitter.io.Buf import java.nio.ByteBuffer object ByteBufferSerializers { def utf8(bb: ByteBuffer): String = Buf.Utf8.unapply(Buf.ByteBuffer.Shared(bb)).get def path(path: Seq[ByteBuffer]): String = path.map(utf8).mkString("/", "/", "") def stamp(bb: ByteBuff...
Explain and rewrite the following Scala code:
package com.eharmony.aloha.models.h2o.compiler import hex.genmodel.GenModel import hex.genmodel.easy.prediction.RegressionModelPrediction import hex.genmodel.easy.{RowData, EasyPredictModelWrapper} import org.junit.Assert._ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.BlockJUnit4Class...
Explain and rewrite the following Scala code:
package com.landoop.streamreactor.connect.hive.parquet import com.landoop.streamreactor.connect.hive.StructUtils import org.apache.hadoop.conf.Configuration import org.apache.hadoop.fs.{FileSystem, Path} import org.apache.kafka.connect.data.{SchemaBuilder, Struct} import org.scalatest.{Matchers, WordSpec} class Parqu...
Explain and rewrite the following Scala code:
package spatutorial.client.services import java.nio.ByteBuffer import boopickle.Default._ import org.scalajs.dom import scala.concurrent.Future import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow import scala.scalajs.js.typedarray._ object AjaxClient extends autowire.Client[ByteBuffer, Pickler, Pick...
Explain and rewrite the following Scala code:
package sbn.core.data.attributes //TODO: Properly create the SparseStateSpace class and seal the StateSpaceType trait. /** * Base trait for the state-space types. */ trait StateSpaceType{ /** * Checks if the provided value belongs to the state space or not. * * @param value the provided value. * ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.psi.util import com.intellij.psi.PsiConstantEvaluationHelper.AuxEvaluator import com.intellij.psi.PsiElement import com.intellij.psi.impl.ConstantExpressionEvaluator import org.jetbrains.plugins.scala.extensions.PsiElementExt import org.jetbrains.plugins.scala.lang.lexer.ScalaT...
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:
/* * 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.monsanto.arch.cloudformation.model.resource import com.monsanto.arch.cloudformation.model.{ConditionRef, ResourceRef, Token} import spray.json.{DefaultJsonProtocol, JsonFormat} case class GenerateSecretString( ExcludeUppercase: Option[Boolean] = None, RequireEachIncludedType: Option[Boolean] = None, ...
Explain and rewrite the following Scala code:
package mesosphere.marathon import org.apache.mesos.Protos._ import org.apache.mesos.{SchedulerDriver, Scheduler} import java.util.logging.{Level, Logger} import scala.collection.JavaConverters._ import scala.collection.mutable.ListBuffer import scala.collection.mutable.HashSet import mesosphere.mesos.TaskBuilder impo...
Explain and rewrite the following Scala code:
package templemore.sbt.cucumber import org.scalatools.testing._ import java.util.Properties /** * Framework implementation that allows cucumber to be run as part of sbt's * standard 'test' phase. * * @author Chris Turner */ class CucumberFramework extends Framework { val name = "cucumber" val tests = Array[...
Explain and rewrite the following Scala code:
import _root_.io.gatling.core.scenario.Simulation import ch.qos.logback.classic.{Level, LoggerContext} import io.gatling.core.Predef._ import io.gatling.http.Predef._ import org.slf4j.LoggerFactory import scala.concurrent.duration._ /** * Performance test for the Course entity. */ class CourseGatlingTest extends Si...