scroll-list-1.0.0.1: This package provides functions for relocate an item within a list.
Copyright(c) Felpe Santa-Cruz 2021
LicenseBSD3
Maintainerfesanmar@gmail.com
Stabilitystable
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.List.Scroll

Description

This module provides functions for relocate an item within a list.

Synopsis

Documentation

up :: Int -> Int -> [a] -> [a] Source #

The up function moves an element n positions to the beginning of a list. If the index provided is out of range, the list is returned without any modification. On the other hand, extra steps will be ignored.

Some examples are given below:

>>> up 2 2 ["one", "two", "three"]
["three", "one", "two"]
>>> up 4 1 ["one", "two", "three"]
["one", "two", "three"]
>>> up 2 3 ["one", "two", "three"]
["three", "one", "two"]

down :: Int -> Int -> [a] -> [a] Source #

The down function moves an element n positions to the end of a list. If the index provided is out of range, the list is returned without any modification. On the other hand, extra steps will be ignored.

Some examples are given below:

>>> down 0 1 ["one", "two", "three"]
["two", "one", "three"]
>>> down 4 1 ["one", "two", "three"]
["one", "two", "three"]
>>> down 0 4 ["one", "two", "three"]
["two", "three", "one"]