felix icon indicating copy to clipboard operation
felix copied to clipboard

Rosetta Code tasks

Open ahribellah opened this issue 4 years ago • 7 comments

In lieu of more extensive documentation, one thing we could do is work on Rosetta Code tasks. These give short, focused examples of how to do different things in the language.

Right now, there is exactly one: https://rosettacode.org/wiki/Category:Felix

There are currently 1081 tasks available: https://rosettacode.org/wiki/Category:Programming_Tasks

I'll probably start chipping away at these soon.

ahribellah avatar Dec 19 '20 21:12 ahribellah

Cool! Please add these to the repository. Let me add a directory for you.

skaller avatar Dec 20 '20 05:12 skaller

would it be advisable to make a pull request for every rosetta code addition? Some rosetta code tasks are highly trivial and require more explanation than code.

razetime avatar Oct 22 '22 06:10 razetime

Neither. I think I added you as a developer. Please check. You should be able to push directly to the repository

skaller avatar Oct 25 '22 23:10 skaller

I'd like to start on the rosetta code additions in a separate branch to verify that the additions are in the most idiomatic form possible. I hope that is ok.

On 10/26/22, John Skaller @.***> wrote:

Neither. I think I added you as a developer. Please check. You should be able to push directly to the repository

-- Reply to this email directly or view it on GitHub: https://github.com/felix-lang/felix/issues/164#issuecomment-1291261616 You are receiving this because you commented.

Message ID: @.***>

razetime avatar Oct 26 '22 06:10 razetime

Sure!

skaller avatar Oct 27 '22 03:10 skaller

Some of the tasks will require reversing and sorting of strings and collections of data (varrays?).

Lists have a rev() function.

Is it planned to add this in the standard library for strings and other data types like varray?

Or is it expected that the user will roll their own, something like:

fun rev[T] (x:varray[T]): varray[T] = {
  var sz = len(x);
  var o = varray[T]$ sz;

  for var i in 0uz upto (sz - 1) do
    push_back (o, x.(sz - 1 - i));
  done
  return o;
}

jlp765 avatar Jan 01 '23 11:01 jlp765

Note that, since Felix strings are C++ strings ... you can always write code in C++ and then embed it in Felix code. If you find you need a routine that should be in the standard library, but isn't, we can always add it in there.

Notice, the varray sort in the standard library is actually C++ standard library sort.

I'm not sure if sorting or reversing a string belongs in the standard library or not, but it really cannot hurt.

I add things to the library when I need them.

skaller avatar Jan 01 '23 22:01 skaller