instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
// Copyright (c) 2015/2016, Thilo Planz. // // This program is free software: you can redistribute it and/or modify // it under the terms of the Apache License, Version 2.0 // as published by the Apache Software Foundation (the "License"). // // Unless required by applicable law or agreed to in writing, // software dis...
Explain and rewrite the following Scala code:
/* Copyright 2009-2011 Jay Conrod * * This file is part of Tungsten. * * Tungsten is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 2 of * the License, or (at your option) any late...
Explain and rewrite the following Scala code:
/* Copyright 2017-18, 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.finagram.api.json import org.json4s.Extraction import org.json4s.native.JsonMethods._ import org.scalatest.{ FreeSpec, Matchers } import ru.finagram.api.{ MarkdownAnswer, _ } import ru.finagram.test.MockitoSugar import ru.finagram.test.matchers.Json import scala.util.Random class AnswerSerializerSpec exte...
Explain and rewrite the following Scala code:
package reasonable import language.higherKinds import scala.util.Success import scalaz.Monad sealed trait ReturnValue[+A] case class Value[A, F[A]](a: A, fa: F[A]) extends ReturnValue[A] case class Error(a: Any) extends ReturnValue[Nothing] object ValueMonad { implicit val valueMonad = new Monad[ReturnValue] { ...
Explain and rewrite the following Scala code:
/* * La Trobe University - Distributed Deep Learning System * Copyright 2016 Matthias Langer (t3l@threelights.de) * * 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.apa...
Explain and rewrite the following Scala code:
/******************************************************************************* * Copyright 2010 Maxime Lรฉvesque * * 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.apa...
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 scalanlp.collection.mutable; /* Copyright 2009 David Hall, Daniel Ramage 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 requir...
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:
package dhg.util import dhg.util.CollectionUtil._ import scala.collection.GenTraversableOnce import scala.collection.mutable import scala.annotation.tailrec import scala.reflect.ClassTag /** * Collections * * @author Dan Garrette (dhgarrette@gmail.com) */ object Collections { /** * A set for which `contains...
Explain and rewrite the following Scala code:
package com.twitter.finagle.postgresql.types import com.twitter.finagle.postgresql.PgSqlClientError import com.twitter.finagle.postgresql.Types.Numeric import com.twitter.finagle.postgresql.Types.NumericSign /** * Some utilities to deal with Postgres' internal numeric representation. */ object PgNumeric { // Num...
Explain and rewrite the following Scala code:
// Wei Chen - Linear Discriminant Analysis // 2017-09-01 import com.scalaml.algorithm.LDA import org.scalatest.funsuite.AnyFunSuite class LDASuite extends AnyFunSuite { val d1 = Array(Array(1.0, 2.1), Array(2.0, 3.2), Array(0.0, 0.0)) val d2 = Array(Array(2.0, 1.1), Array(3.0, 2.2), Array(4.0, 4.0)) val...
Explain and rewrite the following Scala code:
import scala.quoted.* object Foo { def impl(using Quotes) : Unit = { import quotes.reflect.* val Select(_, _) = (??? : Term) } }
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2018 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 scala object Factorial { def calculate( n: Int ) = { fastAccum( n, 1 ) } def fastAccum( n: Int, a: Int ): Int = { if ( n <= 1 ) a else fastAccum( n - 1, a * n ) } } object Runner extends App { val a = Factorial.calculate( 6 ) println( a ) }
Explain and rewrite the following Scala code:
package slamdata.engine.config import slamdata.Predef._ import slamdata.engine._; import Errors._; import Evaluator._ import slamdata.engine.fs._ import org.specs2.mutable._ import org.specs2.scalaz._ class ConfigSpec extends Specification with DisjunctionMatchers { val TestConfig = Config( server = SDServerC...
Explain and rewrite the following Scala code:
/* Copyright 2014 Nest Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing...
Explain and rewrite the following Scala code:
/* * 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 es.weso.shex import org.scalatest.FunSpec import com.typesafe.config._ import com.hp.hpl.jena.rdf.model.ModelFactory import java.io.FileOutputStream import java.io.FileInputStream import scala.collection.JavaConverters._ import org.scalatest.Matchers import es.weso.shacl.Report class RunTestsBack extends FunS...
Explain and rewrite the following Scala code:
package video import com.github.sarxos.webcam.{Webcam => WC} import java.util.concurrent.TimeUnit import akka.stream.actor._ import akka.actor.Props import org.reactivestreams._ import collection.JavaConverters._ import akka.actor.ActorSystem import akka.actor.ActorRefFactory object WebCam { def default(system: Ac...
Explain and rewrite the following Scala code:
package com.stulsoft.pscalafx.demo1 import scalafx.application.{Platform, JFXApp} import scalafx.Includes._ import scalafx.scene.Scene import scalafx.scene.layout.{Priority, ColumnConstraints, GridPane} import scalafx.scene.control.{Button, TextField, ComboBox, Label} import scalafx.geometry.{Insets, HPos} import scal...
Explain and rewrite the following Scala code:
package de.htwg.zeta.parser.shape.check import de.htwg.zeta.parser.ConceptCreatorHelper import de.htwg.zeta.parser.shape.parsetree.GeoModelAttributes.Editable import de.htwg.zeta.parser.shape.parsetree.GeoModelAttributes.For import de.htwg.zeta.parser.shape.parsetree.GeoModelAttributes.Identifier import de.htwg.zeta.p...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Michel Vollebregt * * 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 applica...
Explain and rewrite the following Scala code:
package controllers import javax.inject.{Singleton, Inject} import scala.concurrent.duration._ import play.api.mvc.{Controller, Action} import play.api.mvc.Results.{Ok, BadRequest} import play.api.http.ContentTypes import play.api.libs.json.Json import play.api.libs.concurrent.Execution.Implicits.defaultContext import...
Explain and rewrite the following Scala code:
sealed trait List[+A] case object Nil extends List[Nothing] case class Cons[+A](head: A, tail: List[A]) extends List[A] object List { def apply[A](as: A*): List[A] = { if(as.isEmpty) Nil else Cons(as.head, apply(as.tail: _*)) } def tail[A](items: List[A]): List[A] = ??? def setHead[A](items: List[A], n: A)...
Explain and rewrite the following Scala code:
/* * Copyright 2010-2011 Vilius Normantas <code@norma.lt> * * This file is part of Crossbow library. * * Crossbow 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 ...
Explain and rewrite the following Scala code:
/* * Copyright 2012-2013 Stephane Godbillon (@sgodbillon) and Zenexity * * 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 req...
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 requests import models.LineBuilder import play.api.data.Form import play.api.data.Forms._ import scalikejdbc.{AutoSession, DBSession} case class LineCreate(name: String, stations: Seq[StationCreate], patterns: Seq[PatternCreate]) { private def build: LineBuilder = LineBuilder(name) def save()(implicit se...
Explain and rewrite the following Scala code:
/** * For copyright information see the LICENSE document. */ package entice.server.utils import scala.reflect.runtime.universe._ case class DualMutableMap[T, K]() { var tkMap: Map[T, K] = Map() var ktMap: Map[K, T] = Map() def >>(t: T) : Option[K] = tkMap.get(t) def <<(k: K) : Option[T] = ktMap.g...
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 dotty.tools.languageserver.util.embedded import dotty.tools.languageserver.util.server.TestFile import dotty.tools.languageserver.util.{CodeRange, PositionContext} import scala.collection.JavaConverters._ import org.eclipse.lsp4j._ import PositionContext.PosCtx /** Used to mark positions in the code */ cla...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2013-2013 ICM UW */ package pl.edu.icm.ceon.scala_commons.classification.features /** * @author Mateusz Fedoryszak (m.fedoryszak@icm.edu.pl) */ class FeatureVectorBuilder[A](calculators: List[FeatureCalculator[A]]) { def calculateFeatureVectorValues(obj: A): Array[Double] = calculators.ma...
Explain and rewrite the following Scala code:
package bubblewrap import io.netty.handler.codec.http.DefaultHttpHeaders import io.netty.handler.codec.http.{HttpHeaders => HttpResponseHeaders} import org.scalatest.FlatSpec import org.scalatest.Matchers.{be, convertToAnyShouldWrapper} class ResponseHeadersSpec extends FlatSpec { "ResponseHeader" should "read cont...
Explain and rewrite the following Scala code:
/* * Copyright 2014-15 Intelix Pty 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 agr...
Explain and rewrite the following Scala code:
package eu.tilk.gf import org.scalatest._ abstract class UnitSpec extends WordSpec
Explain and rewrite the following Scala code:
package sangria.validation.rules import sangria.util.{Pos, ValidationSupport} import org.scalatest.wordspec.AnyWordSpec class KnownDirectivesSpec extends AnyWordSpec with ValidationSupport { override val defaultRule = Some(new KnownDirectives) "Validate: Known directives" when { "within query language" shou...
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:
/* * Copyright (C) 2016 University of Basel, Graphics and Vision Research Group * * 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) an...
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 views.html import play.templates._ import play.templates.TemplateMagic._ import play.api.templates._ import play.api.templates.PlayMagic._ import models._ import controllers._ import java.lang._ import java.util._ import scala.collection.JavaConversions._ import scala.collection.JavaConverters._ import play....
Explain and rewrite the following Scala code:
package org.scalatra /** * Mixin for clients that only support a limited set of HTTP verbs. If the * request is a POST and the `_method` request parameter is set, the value of * the `_method` parameter is treated as the request's method. */ trait MethodOverride extends Handler { abstract override def handle(req...
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.dotc package core package tasty import dotty.tools.tasty.{TastyBuffer, TastyReader} import TastyBuffer.NameRef import Contexts._, Decorators._ import Names.Name import TastyUnpickler._ import util.Spans.offsetToInt import dotty.tools.tasty.TastyFormat.{ASTsSection, PositionsSection, CommentsSectio...
Explain and rewrite the following Scala code:
/* * Copyright 2017 Nicolas Rinaudo * * 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...
Explain and rewrite the following Scala code:
package com.ugurayan.scala.tutorial_04 /** * Created by future on 9/20/17. */ object tutorial_04 { println("\n>>>>> TUTORIAL 04 : Traits & Class Composition with Mixins-------------\n") }
Explain and rewrite the following Scala code:
package scorex.network.message import scorex.transaction.Transaction case class TransactionMessage(transaction: Transaction) extends Message { override val messageType = Message.TransactionType override lazy val dataBytes = transaction.bytes() } object TransactionMessage { def apply(data: Array[Byte]): Trans...
Explain and rewrite the following Scala code:
//package io.youi.example.ui // //import io.youi._ //import io.youi.component.Container //import io.youi.example.screen.UIExampleScreen //import io.youi.layout.snap.Snap //import io.youi.net._ //import io.youi.paint.Paint //import reactify._ // //import scala.concurrent.Future // //class SnapExample extends UIExampleSc...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2014 AyaIB Developers (http://github.com/fauu/AyaIB) * * This software is licensed under the GNU General Public License * (version 3 or later). See the COPYING file in this distribution. * * You should have received a copy of the GNU Library General Public License * along with this software. I...
Explain and rewrite the following Scala code:
package pl.touk.nussknacker.engine.kafka.sink import pl.touk.nussknacker.engine.api.editor.{DualEditor, DualEditorMode, SimpleEditor, SimpleEditorType} import pl.touk.nussknacker.engine.api.process.{ProcessObjectDependencies, Sink, SinkFactory} import pl.touk.nussknacker.engine.api.{LazyParameter, MetaData, MethodToIn...
Explain and rewrite the following Scala code:
package org.topicquests.comet import net.liftweb.actor.LiftActor import net.liftweb.http.ListenerManager import org.topicquests.model.ChatLine import org.topicquests.util.DateHelper /** * @author dfernandez * @license Apache2.0 * */ //Case class that represents a line of chat case class FullChatLine(conversastio...
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:
/* * 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.cerner.beadledom.jaxrs import java.net.URI import java.util import java.util.{Collections, Date, Locale} import javax.ws.rs.core._ import com.cerner.beadledom.testing.UnitSpec import org.mockito.Mockito.when import org.scalatest.mockito.MockitoSugar class ResponseToStringWrapperSpec extends UnitSpec wit...
Explain and rewrite the following Scala code:
package models import com.novus.salat.dao._ import com.novus.salat.annotations._ import com.mongodb.casbah.Imports._ import com.novus.salat.{TypeHintFrequency, StringTypeHintStrategy, Context} import play.api.Play import play.api.Play.current package object customMongoContext { implicit val context = { val cont...
Explain and rewrite the following Scala code:
/* * GNU GENERAL PUBLIC LICENSE * Version 2, June 1991 * * Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Everyone is permitted to copy and distribute verbatim copies * of this license document, ...
Explain and rewrite the following Scala code:
package org.jetbrains.sbt.project.data.service import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.externalSystem.model.project.ProjectData import com.intellij.openapi.externalSystem.model.{DataNode, ProjectSystemId} import com.intellij.openapi.externalSystem.service.notification.{No...
Explain and rewrite the following Scala code:
/* ************************************************************************************* * Copyright 2011-2013 Normation SAS ************************************************************************************* * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affe...
Explain and rewrite the following Scala code:
object Test extends App { val c = new C_1 assert(c.nulled == "X\\u0000ABC") // "X\\000ABC" assert(c.supped == "๐’ˆ๐’๐’‘๐’›๐’๐’˜๐’•๐’–") assert(C_1.NULLED == "X\\u0000ABC") // "X\\000ABC" assert(C_1.SUPPED == "๐’ˆ๐’๐’‘๐’›๐’๐’˜๐’•๐’–") assert(C_1.NULLED.size == "XYABC".size) assert(C_1.SUPPED.codePointCount(0, C...
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 2013 Maurรญcio Linhares * * Maurรญcio Linhares licenses this file to you 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:
/* * 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.gilt.gfc.util import org.scalatest.{FunSuite, Matchers} class ZipUtilsTest extends FunSuite with Matchers { private val stuff = Array[String]("Ciao", "Hello", "master", "originators", "GILT") test("zips correctly a simple array of strings") { val actual: Array[String] = ZipUtils.unzip[Array[St...
Explain and rewrite the following Scala code:
package com.lljv.analytics.analyzerengine case class VectorizationSettings ( val modelFolder: Option[String], val appName: String, val sparkMaster: String, val stringSerializerType: String, val stringDeserializerType: String )
Explain and rewrite the following Scala code:
/* Copyright 2013 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 to in writing, software...
Explain and rewrite the following Scala code:
package org.fuckboi.ast import org.objectweb.asm.MethodVisitor import org.objectweb.asm.Opcodes._ import org.objectweb.asm.Label import org.fuckboi.SymbolTable case class WhileNode(condition: OperandNode, statements: List[AstNode]) extends StatementNode { def generate(mv: MethodVisitor, symbolTable: SymbolTable) { ...
Explain and rewrite the following Scala code:
package java.nio private[nio] final class HeapByteBuffer private (_capacity: Int, _array0: Array[Byte], _arrayOffset0: Int, _initialPosition: Int, ...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2022 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:
/******************************************************************************* * Copyright (c) 2019. Carl Minden * * 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 ...
Explain and rewrite the following Scala code:
// // Copyright 2016 Commonwealth Bank of Australia // // 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 ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2005 - 2019 Schlichtherle IT Services. * All rights reserved. Use is subject to license terms. */ package global.namespace.truelicense.tests.v4 import global.namespace.truelicense.tests.swing.LicenseManagementWizardITLike import org.scalatest.wordspec.AnyWordSpec class V4LicenseManagementWizardI...
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 2011-2017 GatlingCorp (http://gatling.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.org/licenses/LICENSE-2.0 * * Unless required by appli...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2019 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and...
Explain and rewrite the following Scala code:
package com.komanov.serialization.converters import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream} import com.komanov.serialization.converters.api.MyConverter import com.komanov.serialization.io.IoUtils.using import com.komanov.serialization.domain.{Site, SiteEvent, SiteE...
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 (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com> */ package com.qifun.statelessFuture package test package neg import org.junit.Test class SampleNegSpec { @Test def `missing symbol`() { expectError("not found: value kaboom") { """ | kaboom """.stripMargin } } }...
Explain and rewrite the following Scala code:
package org.arnoldc.ast import org.objectweb.asm.MethodVisitor import org.objectweb.asm.Opcodes._ import org.arnoldc.SymbolTable case class CallReadMethodNode(returnVar: String) extends StatementNode{ def generate(mv: MethodVisitor, symbolTable: SymbolTable) = { mv.visitTypeInsn(NEW, "java/util/Scanner"); m...
Explain and rewrite the following Scala code:
package io.finch import com.twitter.io.Buf import shapeless.Witness /** * An abstraction that is responsible for encoding the value of type `A`. */ trait Encode[A] { type ContentType <: String def apply(a: A): Buf } trait LowPriorityEncodeInstances { type Aux[A, CT <: String] = Encode[A] { type ContentType...
Explain and rewrite the following Scala code:
package ml.wolfe.term /** * @author riedel */ class LogTerm[D <: Dom, T <: Term[D]](val toLog: T, val name:String = null) extends Term[D] with Unary { def nameToShow = if (name == null) toLog.toString else name type ArgumentType = T def argument = toLog //def isStatic = toLog.isStatic override def t...
Explain and rewrite the following Scala code:
package scala.slick.profile import scala.language.{implicitConversions, higherKinds, existentials} import scala.slick.action._ import scala.slick.ast._ import scala.slick.backend.RelationalBackend import scala.slick.lifted._ import scala.slick.relational._ import scala.slick.util.{TupleMethods, TupleSupport} import Fu...
Explain and rewrite the following Scala code:
/* * Copyright 2019 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 scheme object Util { val gensym: () => SSymbol = { var count: BigInt = 0 () => { count += 1 SSymbol("g" + count) } } }
Explain and rewrite the following Scala code:
package io.toolsplus.atlassian.connect.play.api.repositories import io.toolsplus.atlassian.connect.play.api.models.AtlassianHost import io.toolsplus.atlassian.connect.play.api.models.Predefined.ClientKey import scala.concurrent.Future trait AtlassianHostRepository { /** Retrieves all stored Atlassian Connect host...
Explain and rewrite the following Scala code:
package gapt.proofs.lk.rules.macros import gapt.expr.Expr import gapt.expr.formula.All import gapt.expr.formula.Ex import gapt.expr.formula.Formula import gapt.proofs.lk.LKProof object WeakQuantifierBlock { def apply( p: LKProof, main: Formula, terms: Seq[Expr] ): LKProof = main match { case _ if terms.is...
Explain and rewrite the following Scala code:
package com.bazaarvoice.sswf.heartbeat import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient import com.amazonaws.services.simpleworkflow.model._ import com.bazaarvoice.sswf._ import com.bazaarvoice.sswf.model.history.{StepEvent, StepsHistory} import com.bazaarvoice.sswf.model.result.{StepResult, Suc...
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 tests.distribution.delta import kofre.decompose.LexPair._ import kofre.decompose.UIJDLattice._ import kofre.decompose.{LexPair, UIJDLattice} import org.scalacheck.{Arbitrary, Gen} import org.scalatest.freespec.AnyFreeSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks class IntAsUIJDLattic...
Explain and rewrite the following Scala code:
package example import domala.Holder @Holder case class Name(value: String)
Explain and rewrite the following Scala code:
package com.rklaehn.abc import algebra.Eq object Instances { implicit class OptionIntSyntax(lhs: Option[Int]) { def +(rhs: Option[Int]) : Option[Int] = (lhs, rhs) match { case (Some(x), Some(y)) โ‡’ Some(x + y) case _ โ‡’ None } } implicit class EqSyntax[T: Eq](lhs: T) { def ===(rhs: T) = ...
Explain and rewrite the following Scala code:
package es.upm.fi.oeg.morph.tc class D019Test extends R2RMLTest("D019-1table1primarykey3columns3rows") { "TC019a" should "gen 2 in DG" in{ val dg=generate("R2RMLTC0019a") dg.getDefaultGraph.size should be (2) } "TC019b" should "gen 3 in DG" in{ val dg=generate("R2RMLTC0019b") dg.getDefaultGraph.size shoul...
Explain and rewrite the following Scala code:
package com.atomist.source.filter case class GitignoreFileFilter(override val rootPath: String) extends PatternMatchableArtifactFilter(rootPath) { override protected def filePath: String = ".gitignore" }
Explain and rewrite the following Scala code:
package com.github.jlprat.ninetynine.p06 /** * Created by @jlprat on 01/03/2016. * P06: Find out if a list is a palindrome * Difficulty: * */ object P06 { /** * Checks if the elements in the list form a palindrome * @param list the list to be checked if its elements form a palindrome * @tparam A...
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:
package example object Hello extends App { trait Impl { def hello: String } trait M extends Impl { //ใ‚คใƒณใ‚ฟใƒผใƒ•ใ‚งใƒผใ‚นใ‚’็ถ™ๆ‰ฟใ™ใ‚‹ override def hello = "i am mama" } trait P extends Impl { //ใ‚คใƒณใ‚ฟใƒผใƒ•ใ‚งใƒผใ‚นใ‚’็ถ™ๆ‰ฟใ™ใ‚‹ override def hello = "i am papa" } trait C { def shout(t: String): String = { "%s Gyaaa!!!".f...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2010 Mark Harrah */ package sbt package inc import java.io.File import Relations.Source import Relations.SourceDependencies import xsbti.api.{ Source => APISource } import xsbti.DependencyContext import xsbti.DependencyContext._ /** * Provides mappings between source files,...
Explain and rewrite the following Scala code:
package services import models.Bio import sql.{ Bios, Users } import scala.concurrent.Future import java.util.UUID import slick.driver.H2Driver.api._ import Bios._ import Users._ class BioService(database: Database) extends DatabaseService(Bios, database) { def findOneByUserSlug(slug: String): Future[Option[Bio]]...
Explain and rewrite the following Scala code:
package com.github.mpetruska.ukmodulo.digits import com.github.mpetruska.ukmodulo.Error import scala.language.postfixOps case class AccountDigits private[ukmodulo] (digits: Vector[Int]) { require(digits.length == 14) require(digits.forall(0 <=)) require(digits.forall(9 >=)) } object AccountDigits { val sor...