Functions

The following functions are available globally.

  • Undocumented

  • Lazily return a sequence containing the elements of source, in order, that satisfy the predicate includeElement

    Declaration

    Swift

    public func filter <S : SequenceType>
    	(includeElement: (S.Generator.Element) -> Bool)
    	(source: S)
    	-> LazySequence<FilterSequenceView<S>>
  • Return an Array containing the sorted elements of source according to ‘isOrderedBefore’.

    Requires: isOrderedBefore is a strict weak ordering <http://en.wikipedia.org/wiki/Strict_weak_order#Strict_weak_orderings> over elements.

    Declaration

    Swift

    public func sorted <S : SequenceType>
    	(isOrderedBefore: (S.Generator.Element, S.Generator.Element) -> Bool)
    	(source: S)
    	-> [S.Generator.Element]
  • Lazily return a sequence containing the results of mapping transform over source.

    Declaration

    Swift

    public func map <S: SequenceType, T>
    	(transform: (S.Generator.Element) -> T)
    	(source: S)
    	-> LazySequence<MapSequenceView<S, T>>
  • Return the result of repeatedly calling combine with an accumulated value initialized to initial and each element of sequence, in turn.

    Declaration

    Swift

    public func reduce <S : SequenceType, U>
    	(initial: U, combine: (U, S.Generator.Element) -> U)
    	(sequence: S)
    	-> U
  • Split text over delimiter, returning an array.

    Declaration

    Swift

    public func split (_ delimiter: String = "\n")(text: String) -> [String]
  • Insert separator between each item in elements.

    Declaration

    Swift

    public func join <C : ExtensibleCollectionType, S : SequenceType where S.Generator.Element == C>
    	(separator: C)
    	(elements: S)
    	-> C
  • Turn a sequence into an array. For use after the |> operator.

    Declaration

    Swift

    public func toArray <S : SequenceType> (sequence: S) -> [S.Generator.Element]
  • Discard all elements in tobedropped from sequence.

    Declaration

    Swift

    public func drop <S : SequenceType, T : Equatable where S.Generator.Element == T>
    	(tobedropped: [T])
    	(sequence: S)
    	-> LazySequence<FilterSequenceView<S>>
  • Return at most the first numbertotake elements of sequence

    Declaration

    Swift

    public func take <S : SequenceType, T where S.Generator.Element == T>
    	(numbertotake: Int)(sequence: S) -> [T]
  • Print message to standard error and halt execution.

    Declaration

    Swift

    @noreturn public func printErrorAndExit (errormessage: String)
  • Open a file for reading, and exit if an error occurs.

    Declaration

    Swift

    public func open (path: String) -> ReadableStreamType
  • Open a file for writing, create it if it doesn’t exist, and exit if an error occurs. If the file already exists and overwrite=false, the writing will begin at the end of the file.

    Declaration

    Swift

    public func open (forWriting path: String, overwrite: Bool = false) -> WriteableStreamType

    Parameters

    overwrite

    If true, replace the file if it exists.

  • Create a stream from a String.

    Declaration

    Swift

    public func stream (text: String) -> ReadableStreamType
  • Create a stream from a function returning a generator function, which is called every time the stream is asked for more text.

    stream { // initialisation… return { // called repeatedly by the resulting stream // return text, or return nil when done. } }

    Declaration

    Swift

    public func stream ( closure:() -> () -> String? ) -> ReadableStreamType

    Return Value

    The output stream.

  • Create a stream from a sequence of Strings.

    Declaration

    Swift

    public func stream <Seq : SequenceType where Seq.Generator.Element == String> (sequence: Seq) -> ReadableStreamType
  • Return a writable stream and a readable stream. What you write to the 1st one can be read from the 2nd one. Make sure to call closeStream() on the writable stream before you call read() on the readable one.

    Declaration

    Swift

    public func streams () -> (WriteableStreamType, ReadableStreamType)
  • Split a stream lazily

    Declaration

    Swift

    public func split (delimiter: String = "\n")(stream: ReadableStreamType) -> SequenceOf<String>
  • Write something to a stream.

    something |> writeTo(writablestream)
    

    Declaration

    Swift

    public func writeTo <T> (stream: WriteableStreamType)(input: T)
  • Write a String to a writable stream.

    Declaration

    Swift

    public func writeTo (stream: WriteableStreamType)(input: String)
  • Write a sequence to a stream.

    Declaration

    Swift

    public func writeTo <S : SequenceType> (stream: WriteableStreamType)(seq: S)
  • Write something to a stream.

    something |>> writablestream

    Declaration

    Swift

    public func |>> <T> (input: T, stream: WriteableStreamType)
  • Write a String to a writable stream.

    Declaration

    Swift

    public func |>> (text: String, stream: WriteableStreamType)
  • Write a sequence to a stream.

    Declaration

    Swift

    public func |>> <S : SequenceType> (seq: S, stream: WriteableStreamType)
  • Specific handling of func run (shellcommand: String) -> ReadableStreamType on the right side using the stream on the left side as standard input.

    Warning: is only meant to be used with the run command, but could also unintentionally catch other uses of ReadableStreamType |> ReadableStreamType, though that statement doesn’t make any sense.

    Declaration

    Swift

    public func |> (lhs: ReadableStreamType, @autoclosure rhs:  () -> ReadableStreamType) -> ReadableStreamType
  • Run a shell command synchronously with no standard input, or if to the right of a ReadableStreamType |>, use the stream on the left side as standard input.

    Declaration

    Swift

    public func run (shellcommand: String) -> ReadableStreamType

    Return Value

    Standard output

  • Shortcut for in-line command, returns output as String.

    Declaration

    Swift

    public func $ (shellcommand: String) -> String
  • Turn a sequence into valid parameters for a shell command, properly quoted

    Declaration

    Swift

    public func parameters <S : SequenceType> (sequence: S) -> String
  • Allows for "/directory" / "file.extension" etc.

    Declaration

    Swift

    public func / (leftpath: String, rightpath: String) -> String