simple_rosetta

User Guide

Getting Started

Installation

  1. Set the environment variable:
    export SIMPLE_EIFFEL=/path/to/simple_eiffel_root
  2. Add to your ECF file:
    <library name="simple_rosetta" location="$SIMPLE_EIFFEL/simple_rosetta/simple_rosetta.ecf"/>

Your First Query

class
    MY_APP

feature
    rosetta: SIMPLE_ROSETTA
        once
            create Result.make
        end

    demo
        local
            l_results: ARRAYED_LIST [TUPLE [task: STRING; tier: INTEGER; class_name: STRING]]
        do
            -- Search for sorting solutions
            l_results := rosetta.search_solutions ("sort")
            across l_results as r loop
                print (r.task + " (Tier " + r.tier.out + ")%N")
            end
        end
end

Understanding Solution Tiers

Solutions are organized by difficulty to help you find appropriate examples:

Tier Difficulty Typical Tasks
1 Trivial Hello World, Boolean values, Empty program, String operations
2 Easy FizzBuzz, File I/O, Date formatting, Environment variables
3 Moderate Sorting algorithms, Data structures, Date calculations
4 Complex Graph algorithms, Recursive solutions, Advanced DbC

Searching Solutions

By Keyword

local
    l_results: ARRAYED_LIST [TUPLE [task: STRING; tier: INTEGER; class_name: STRING]]
do
    l_results := rosetta.search_solutions ("fibonacci")
    across l_results as r loop
        print (r.task + "%N")
    end
end

By Tier

local
    l_solutions: ARRAYED_LIST [TUPLE [task: STRING; class_name: STRING; file: STRING]]
do
    -- Get all Tier 1 (trivial) solutions
    l_solutions := rosetta.solutions_by_tier (1)
    print ("Found " + l_solutions.count.out + " trivial solutions%N")
end

Generating Wiki Format

Generate copy-paste-ready Rosetta Code wiki markup:

if attached rosetta.solution_as_wiki ("Fibonacci_sequence") as l_wiki then
    print (l_wiki)
    -- Output:
    -- =={{header|Eiffel}}==
    -- <syntaxhighlight lang="eiffel">
    -- ... solution code ...
    -- </syntaxhighlight>
end

Using the CLI

Search Solutions

rosetta search sort
rosetta search fibonacci

List by Tier

rosetta list 1    # Trivial solutions
rosetta list 4    # Complex solutions

Generate Wiki Format

rosetta wiki Fibonacci_sequence

View Statistics

rosetta stats

Submitting to Rosetta Code

  1. Find a task that needs an Eiffel solution
  2. Generate the wiki format: rosetta wiki Task_name
  3. Go to the Rosetta Code wiki page
  4. Click "Edit" and paste the generated markup
  5. Preview and save your changes

Submission Guidelines

  • All solutions include the Simple Eiffel branding
  • Solutions demonstrate proper Design by Contract
  • Code follows Eiffel style conventions
  • Solutions compile and run correctly