instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package org.ai4fm.proofprocess.core.prefs
import org.ai4fm.proofprocess.core.PProcessCorePlugin
import org.eclipse.core.runtime.Platform
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer
import org.eclipse.core.runtime.preferences.DefaultScope
import org.eclipse.core.runtime.preferences.Instanc... |
Explain and rewrite the following Scala code: | package com.michalplachta.shoesorter
import akka.actor.{ ActorLogging, Actor, Props }
import com.michalplachta.shoesorter.Messages._
class DecidersGuardian extends Actor with ActorLogging {
def receive = {
case m: WhereShouldIGo ⇒
val name = s"decider-${m.junction.id}"
val actor = context.child(name... |
Explain and rewrite the following Scala code: | package co.enear.fs2.kafka
import org.apache.kafka.clients.producer._
case class ProducerMessage[K, V, Passthrough](producerRecord: ProducerRecord[K, V], passthrough: Passthrough)
case class ProducerMetadata[PassThrough](metadata: RecordMetadata, passThrough: PassThrough)
|
Explain and rewrite the following Scala code: | package com.jayway.textmining
import java.io.File
import org.apache.commons.io.FileUtils
/**
* Copyright 2012 Amir Moulavi (amir.moulavi@gmail.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... |
Explain and rewrite the following Scala code: | package ml.combust.mleap.bundle.ops.feature
import ml.combust.bundle.BundleContext
import ml.combust.bundle.dsl._
import ml.combust.bundle.op.OpModel
import ml.combust.mleap.bundle.ops.MleapOp
import ml.combust.mleap.core.feature.{MultinomialLabelerModel, ReverseStringIndexerModel}
import ml.combust.mleap.runtime.Mlea... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 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 agreed to... |
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: | /*
* Copyright 2015-2016 IBM Corporation
*
* 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 agree... |
Explain and rewrite the following Scala code: | /*
* ******************************************************************************
* * Copyright (C) 2013 Christopher Harris (Itszuvalex)
* * Itszuvalex@gmail.com
* *
* * This program is free software; you can redistribute it and/or
* * modify it under the terms of the GNU General Public License
* * as p... |
Explain and rewrite the following Scala code: | package chapter.eleven
import scala.collection.mutable.ListBuffer
object ExerciseFive {
case class Table() {
private val cells: ListBuffer[ListBuffer[String]] = ListBuffer(ListBuffer())
def |(cell: String): Table = {
cells.last += cell
this
}
def ||(cell: String): Table = {
cel... |
Explain and rewrite the following Scala code: | package com.github.davidhoyt.fluxmuster
import scala.util.Random
object LinkGenerators {
import org.scalacheck.{Arbitrary, Gen}
import Implicits._
import scala.language.existentials
case class GeneratedLink(default: Any, link: Link[Any, Any])
case class Links(default: Any, links: Vector[Link[_, _]])
ob... |
Explain and rewrite the following Scala code: | package ch31_graph
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.util.control.Breaks._
class Graph(vertex: Array[String]) {
require(vertex.nonEmpty, "nonEmpty vertex required")
val adjacency = new Array[mutable.MutableList[String]](vertex.length)
for (i <- Range(0, ve... |
Explain and rewrite the following Scala code: | package era7bio.db.16s18s.test
import ohnosequences.statika._, aws._
import ohnosequences.awstools._, regions._, ec2._, autoscaling._, s3._
import era7bio.defaults._
case object db16s18s {
// use `sbt test:console`:
// > era7bio.db.test.db16s18s.launch(...)
def launch[
B <: AnyBundle,
T <: AnyInstanceT... |
Explain and rewrite the following Scala code: | /*
* 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 copyright ownership.
*/
// GENERATED CODE: DO NOT EDIT... |
Explain and rewrite the following Scala code: | package graphique.http
import graphique.GraphiqueService
import GraphiqueService.Image
import spray.json.DefaultJsonProtocol
object JsonProtocol extends DefaultJsonProtocol {
implicit val ImageFormat = jsonFormat1(Image)
} |
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 demo.akka.mapreduce
import akka.actor.ActorSystem
import akka.actor.Props
import demo.akka.mapreduce.actor.ControllerActor
import demo.akka.mapreduce.data._
object MapReduceDemoApp {
def main(args: Array[String]) {
val _system = ActorSystem("MapReduceApp")
val controller = _system.actorOf(Props[Control... |
Explain and rewrite the following Scala code: | package org.wartremover
package contrib.warts
/**
* Forbids use of
* - java.util.{ Date, Calendar, GregorianCalendar, TimeZone }
* - java.text.{ DateFormat, SimpleDateFormat }
* - org.joda.time._
*/
object OldTime extends WartTraverser {
val javaError = "The old Java time API is disabled. Use Java 8 java.ti... |
Explain and rewrite the following Scala code: | /* SimpleApp.scala */
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import org.apache.spark.mllib.linalg.{Vector, Vectors, SparseVector, Matrix, Matrices}
import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.mllib.linalg.distribut... |
Explain and rewrite the following Scala code: | package com.flowy.binance
import com.flowy.common.utils.sql.SqlDatabase
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}
class SqlBinanceDao(protected val database: SqlDatabase)(implicit val ec: ExecutionContext)
extends SqlBinanceTickerSchema {
import database._
import ... |
Explain and rewrite the following Scala code: | package com.quantifind.kafka.offsetapp
import com.quantifind.kafka.OffsetGetter.OffsetInfo
trait OffsetInfoReporter {
def report(info: IndexedSeq[OffsetInfo])
def cleanupOldData() = {}
}
|
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 net.ruippeixotog.scalascraper.browser
import java.net.{InetSocketAddress, Proxy}
import akka.http.scaladsl.server.Directives._
import org.specs2.mutable.Specification
import net.ruippeixotog.scalascraper.SocksTestHelper
class JsoupBrowserSpec extends Specification with TestServer with SocksTestHelper {
l... |
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 ... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2019 Inera AB (http://www.inera.se)
*
* This file is part of statistik (https://github.com/sklintyg/statistik).
*
* statistik 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 v... |
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: | /*
* Copyright 2021 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | package org.sisioh.aws4s.s3.model
import java.io.{ File, InputStream }
import com.amazonaws.services.s3.model._
import org.sisioh.aws4s.PimpedType
class RichAbstractPutObjectRequest(val underlying: AbstractPutObjectRequest) extends AnyVal with PimpedType[AbstractPutObjectRequest] {
def bucketName: String = underl... |
Explain and rewrite the following Scala code: | package io.finch.eval
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.twitter.finagle.Http
import com.twitter.io.Buf
import com.twitter.util.{Await, Eval}
import io.finch._
import io.finch.jackson._
/**
* A simple Finch application evaluating... |
Explain and rewrite the following Scala code: | package ohnosequences.scarph.test.titan
// import org.scalatest._
import com.thinkaurelius.titan.example.GraphOfTheGodsFactory
import com.thinkaurelius.titan.core._
import java.io.File
import GodsSchema._
import GodsImplementation._
import ohnosequences.scarph._
class TitanSuite extends org.scalatest.FunSuite with... |
Explain and rewrite the following Scala code: | package org.scaladebugger.test.info
/**
* Provides test of examining variable values that include nested objects.
*
* @note Should have a class name of org.scaladebugger.test.info.NestedObjects
*/
object NestedObjects {
case class Data(x: Int, y: String)
class Container {
val immutableData: Data = Data(3, ... |
Explain and rewrite the following Scala code: | /*
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* 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 b... |
Explain and rewrite the following Scala code: | package com.twitter.finagle
import com.twitter.app.Flaggable
import com.twitter.io.Buf
import com.twitter.finagle.util.Showable
import java.nio.charset.Charset
import java.util.BitSet
/**
* A Path comprises a sequence of byte buffers naming a
* hierarchically-addressed object.
*/
case class Path(elems: Buf*) {
r... |
Explain and rewrite the following Scala code: | /*
* 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 copyright ownership.
*/
package scala.tools.util
impo... |
Explain and rewrite the following Scala code: | package net.debasishg.codemesh.domain.trade
package model
import java.util.{ Date, Calendar }
import scalaz._
import Scalaz._
import \\/._
trait TradeModel {this: RefModel =>
case class Trade(account: Account, instrument: Instrument, refNo: String, market: Market,
unitPrice: BigDecimal, quantity: BigDecimal, ... |
Explain and rewrite the following Scala code: | package com.lvxingpai.model.misc
import javax.validation.constraints.Min
import org.hibernate.validator.constraints.{ Length, NotBlank }
import org.mongodb.morphia.annotations.Embedded
/**
* 图像数据
*
* Created by zephyre on 10/20/15.
*/
@Embedded
class ImageItem {
// /**
// * 图像的裁剪信息
// *
// * @par... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package codeInspection.methodSignature
import com.intellij.codeInspection._
import com.intellij.psi.PsiElement
import org.jetbrains.plugins.scala.codeInspection.methodSignature.quickfix.RemoveEqualsSign
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunctionDefinition
... |
Explain and rewrite the following Scala code: | import scala.language.dynamics
object Test extends App {
object stubUpdate {
def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")"))
}
object stub {
def apply = {println(".apply"); stubUpdate}
def apply(as: Any*) = println(".apply"+as.toList.mkString("(",", ", ")"))
def update... |
Explain and rewrite the following Scala code: | /*
* Copyright 2006-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applica... |
Explain and rewrite the following Scala code: | /*
* Sonification.scala
* (SysSon)
*
* Copyright (c) 2013-2017 Institute of Electronic Music and Acoustics, Graz.
* Copyright (c) 2014-2019 Hanns Holger Rutz. All rights reserved.
*
* This software is published under the GNU General Public License v3+
*
*
* For further information, please contact Hanns Ho... |
Explain and rewrite the following Scala code: | /**
* @author Victor Caballero (vicaba)
* @author Xavier Domingo (xadobu)
*/
package transaction
import transaction.operation._
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
/**
*
* @param attribute
*/
case class NoOperation(override val attribute: String = "noAttr") extends Oper... |
Explain and rewrite the following Scala code: | implicit def state[S] = new Adjunction[Prod[S, ?], Reader[S, ?]] {
def counit[A](a: Prod[S, Reader[S, A]]): A = a match {
case Prod((Reader(f), s)) => f(s)
}
def unit[A](a: A): Reader[S, Prod[S, A]] =
Reader(s => Prod((a, s)))
} |
Explain and rewrite the following Scala code: | package com.truecar.mleap.demo.server.support
import com.truecar.mleap.runtime.LocalLeapFrame
/**
* Created by hwilkins on 1/20/16.
*/
case class TransformRequest(frame: LocalLeapFrame)
case class TransformResponse(frame: LocalLeapFrame)
|
Explain and rewrite the following Scala code: | package edu.depauw.scales.reactive
import scala.scalajs.js
import js.annotation.JSExport
import org.scalajs.dom
import rx._
import edu.depauw.scales.graphics._
import edu.depauw.scales.music._
import edu.depauw.scales.act._
import Base._
/*
** Usage example: Not called directly by user
*/
sealed trait Reactive {}
c... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2015 by its authors. Some rights reserved.
* See the project homepage at: http://www.monifu.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://... |
Explain and rewrite the following Scala code: | package com.rasterfoundry.backsplash.export
import geotrellis.proj4.{CRS, WebMercator}
import geotrellis.vector.Extent
import geotrellis.raster.io.geotiff._
import geotrellis.raster.io.geotiff.compression._
import geotrellis.raster._
import simulacrum._
import cats.effect._
/**
* Allows arbitrary types to encode ex... |
Explain and rewrite the following Scala code: | package computerdatabase.gatling.functional
import computerdatabase.gatling.ComputerDatabaseChainBuilder
import gatling.blueprint.ConfigurationTool.coordinates
import gatling.blueprint.{ConfigurableSimulation, DefaultHttpProtocolBuilder}
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
... |
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 dbtarzan.db.actor
import java.nio.file.Path
import java.sql.{Connection, SQLException}
import java.time.LocalDateTime
import akka.actor.{Actor, ActorRef}
import dbtarzan.config.connections.ConnectionData
import dbtarzan.config.password.EncryptionKey
import dbtarzan.db._
import dbtarzan.db.util.ExceptionToText
... |
Explain and rewrite the following Scala code: | package com.eigengo.lift.profile
import akka.actor.{ActorLogging, Props}
import akka.contrib.pattern.ShardRegion
import akka.persistence.{PersistentActor, SnapshotOffer}
import com.eigengo.lift.common.{UserId, AutoPassivation}
import com.eigengo.lift.notification.NotificationProtocol.{Device, Devices}
object UserProf... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
import mesosphere.marathon.state.PathId
class Exception(msg: String) extends scala.RuntimeException(msg)
class StorageException(msg: String) extends Exception(msg)
class UnknownAppException(id: PathId) extends Exception(s"App '$id' does not exist")
class BadRequestException(msg: String)... |
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.wincom.dcim.message.driver;
/**
* Created by wangxy on 17-9-11.
*/
trait Command extends com.wincom.dcim.message.common.Command {
def driverId: String
override def entityId: String = {
s"driver_${driverId}"
}
}
|
Explain and rewrite the following Scala code: | /** Copyright 2015 TappingStone, 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 ... |
Explain and rewrite the following Scala code: | package com.rasterfoundry.datamodel
import io.circe.generic.JsonCodec
@JsonCodec
final case class License(shortName: String,
name: String,
url: String,
osiApproved: Boolean,
id: Long)
|
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: | /*
* Copyright 2013-2015 Websudos, Limited.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of c... |
Explain and rewrite the following Scala code: | /* Scala.js compiler
* Copyright 2013 LAMP/EPFL
* @author Sébastien Doeraene
*/
package org.scalajs.core.compiler
import scala.tools.nsc._
import scala.tools.nsc.io.AbstractFile
import scala.reflect.internal.pickling.PickleBuffer
import java.io._
import org.scalajs.core.ir
import ir.Infos
/** Send JS ASTs to 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 ... |
Explain and rewrite the following Scala code: | /*
* Scala.js (https://www.scala-js.org/)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.testsuite.javalib.util.con... |
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 org.scalaide.core.internal.jdt.model
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
import scala.tools.nsc.symtab.Flags
import org.scalaide.logging.HasLogger
import org.eclipse.jdt.core._
import org.eclipse.jdt.internal.core.JavaModelManager
import org.eclipse.core.runtime.Path
import org... |
Explain and rewrite the following Scala code: | package scala.meta.tests
package parsers
import scala.meta._, Defn.Class
import scala.meta.dialects.Scala211
class PackageSuite extends ParseSuite {
test("class C") {
val Source(Class(Nil, Type.Name("C"), Nil, EmptyCtor(), EmptyTemplate()) :: Nil) = source("class C")
}
test("package foo; class C") {
va... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2018 OVO Energy
*
* 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, modify, merge, publish,... |
Explain and rewrite the following Scala code: | package com.socrata.http.client
import java.io.{ByteArrayOutputStream, InputStream}
import com.rojoma.json.v3.ast.JValue
import com.rojoma.json.v3.codec.JsonEncode
import com.rojoma.json.v3.io.{JsonEvent, JValueEventIterator}
import com.socrata.http.common.util.HttpUtils
import com.socrata.http.common.livenesscheck.L... |
Explain and rewrite the following Scala code: | package com.rzethon.marsexp.event
import akka.NotUsed
import akka.actor.{ActorRef, ActorSystem}
import akka.event.Logging
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.stream.Ac... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015 Thomson Reuters
*
* Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ag... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2015-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: | package com.olvind.requiresjs
// semi-solves circular dependencies
final class Lazy[+T](_t: => T) {
lazy val run: T = _t
def map[U](f: T => U): Lazy[U] =
new Lazy(f(_t))
def flatMap[U](f: T => Lazy[U]) =
new Lazy(f(_t).run)
}
object Lazy {
def apply[T](_t: => T) =
new Lazy(_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: | package com.github.ldaniels528.broadway.core.io.trigger.impl
import java.io.File
import com.github.ldaniels528.broadway.core.io.archive.Archive
/**
* Represents a Directory which may contain file files
* @author lawrence.daniels@gmail.com
*/
case class FileFeedDirectory(path: String, feeds: Seq[FileFeed], arch... |
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 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 org.macrogl
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
import scala.collection._
class AttributeBuffer(
val usage: Int,
val capacity: Int,
val totalAttributes: Int,
val attributes: Array[(Int, Int)]
)(implicit gl: Macrogl) extends VertexBuffer {
privat... |
Explain and rewrite the following Scala code: | package work.martins.simon.expect
package object dsl {
//Useful conversion to use in returningExpect actions, which are waiting to receive a core.Expect
implicit def dslToCoreExpect[R](expect: Expect[R]): core.Expect[R] = expect.toCore
}
|
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 io.really.io.socket
import akka.actor._
import _root_.io.really._
import _root_.io.really.io.{ AccessTokenInfo, IOGlobals }
import _root_.io.really.protocol.Protocol
import org.joda.time.DateTime
import play.api.libs.json._
import play.api.libs.functional.syntax._
import play.api.mvc.{ Session, RequestHeader }... |
Explain and rewrite the following Scala code: | package monocle.std
import monocle.TestUtil._
import monocle.function._
import monocle.law.{OptionalLaws, PrismLaws}
import org.specs2.scalaz.Spec
class CharSpec extends Spec {
checkAll("Char index bit", OptionalLaws(index[Char, Int, Boolean](0)))
checkAll("Char to Boolean ", PrismLaws(charToBoolean))
}
|
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: | package test
import Factory.FactoryPlurinominal
import Gvote._
import implementationPlurinominale._
import GUI._
import org.scalatest.FunSuite
class testPlurinominale extends FunSuite{
var systeme : SystemeDecomptagePlurinomial = FactoryPlurinominal.createCountingSystem(2, List(2,1))
println(systeme.... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.api.v2.json
import mesosphere.marathon.MarathonSpec
import mesosphere.marathon.api.v2.AppUpdate
import mesosphere.marathon.state.AppDefinition
import org.scalatest.Matchers
import play.api.libs.json.{ Json, JsResultException }
class AppUpdateFormatTest extends MarathonSpec with Matchers {
... |
Explain and rewrite the following Scala code: | package server
import akka.io.{ IO, Tcp }
import java.net.InetSocketAddress
import util._
import handler._
import akka.actor.Props
import akka.actor.ActorRef
import java.util.ArrayList
import akka.io.Tcp.Bound
import akka.actor.ActorLogging
import java.util.UUID
object TcpServer {
def props(handlerProps: HandlerPro... |
Explain and rewrite the following Scala code: | // Copyright 2014 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 ap... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Thomas Puhl
*
* 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 w... |
Explain and rewrite the following Scala code: | package debop4s.timeperiod.timerange
import debop4s.timeperiod.TimeSpec._
import debop4s.timeperiod._
import debop4s.timeperiod.utils.Times
import org.joda.time.DateTime
@SerialVersionUID(2876823794105220883L)
class HourRange(private[this] val _moment: DateTime,
private[this] val _calendar: ITimeCalen... |
Explain and rewrite the following Scala code: | import scala.deriving.*
import scala.quoted.*
object Macro2 {
trait TC[T] {
def test(): Unit
}
object TC {
def derived[T: Type](ev: Expr[Mirror.Of[T]])(using Quotes): Expr[TC[T]] = '{
new TC[T] {
def encode(): Unit = $ev match {
case '{ $m: Mirror.ProductOf[T] } => ??? // error
... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2020 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | /*
* 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 colossus.extensions.protocols.mongo.command
import colossus.extensions.util.bson.BsonDocument
import colossus.extensions.util.bson.BsonDsl._
import colossus.extensions.util.bson.Implicits._
case class Insert(databaseName: String,
collectionName: String,
documents: Seq[BsonD... |
Explain and rewrite the following Scala code: | package interretis.utils
object Resources {
val mainResources = "src/main/resources"
}
|
Explain and rewrite the following Scala code: | /*
* Distributed as part of Scalala, a linear algebra library.
*
* Copyright (C) 2008- Daniel Ramage
*
* This library 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.1 of the ... |
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: | import improving.reflect._
object ReflectionTests {
// scala> (List(1,2,3): Any).toManifest
// res0: scala.reflect.Manifest[_] = scala.collection.immutable.$colon$colon
//
// scala> (List(1,2,3): Any).toClass
// res1: java.lang.Class[_] = class scala.collection.immutable.$colon$colon
//
// scala> Li... |
Explain and rewrite the following Scala code: | package blended.updater.config
import scala.reflect.{ClassTag, classTag}
import scala.util.Success
import scala.util.control.NonFatal
import blended.updater.config.json.PrickleProtocol._
import blended.util.logging.Logger
import org.scalacheck.Gen
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers... |
Explain and rewrite the following Scala code: | /* Copyright 2009-2016 EPFL, Lausanne */
import leon.annotation._
import leon.lang._
object OperatorEquals4 {
abstract class Top
case class ChildA(x: Int) extends Top
case class ChildB(y: Boolean) extends Top
def foo = ChildA(42)
def bar = ChildB(true)
def factory(zero: Int): Top = if (zero == 0) foo e... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.http.filter
import com.twitter.finagle._
import com.twitter.finagle.http.Request
import com.twitter.finagle.http.codec.HttpContext
import com.twitter.util.Future
/**
* Sets the following Context values from the request headers:
* - request deadline
*/
private[finagle] class ServerCo... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2017 Orbeon, Inc.
*
* This program 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.1 of the License, or (at your option) any later version.
*
* This p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.