Login
|
Signup
langref.org
-
scala
add..
all
clojure
cpp
csharp
erlang
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
ruby
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Lists
Modification
Remove an element from a list by index
Given the list
[Apple, Banana, Carrot]
, remove the first element to produce the list
[Banana, Carrot]
scala
val (fl, fr) = fruit.splitAt(0) ; fruit = fl ::: fr.tail
object SolutionXX extends Application {
var fruit = "Apple" :: "Banana" :: "Carrot" :: Nil
val (fl, fr) = fruit.splitAt(0) ; fruit = fl ::: fr.tail
println(fruit)
}
scala
fruit = fruit.tail
object SolutionXX extends Application {
var fruit = "Apple" :: "Banana" :: "Carrot" :: Nil
fruit = fruit.tail
println(fruit)
}
scala
fruit = fruit.drop(1)
object SolutionXX extends Application {
var fruit = "Apple" :: "Banana" :: "Carrot" :: Nil
fruit = fruit.drop(1)
println(fruit)
}
scala
fruits = fruits.remove(fruits.indexOf(_) == 0)
object Solution1287 extends Application {
var fruits = List("Apple", "Banana", "Carrot")
fruits = fruits.remove(fruits.indexOf(_) == 0)
println(fruits)
}
Submit a new solution for
scala
There are 26 other solutions in
additional
languages (
clojure
,
cpp
,
csharp
,
erlang
...)