felix-lang / felix

The Felix Programming Language
Other
803 stars 43 forks source link

Rosetta Code tasks #164

Open ahribellah opened 3 years ago

ahribellah commented 3 years ago

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.

skaller commented 3 years ago

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

razetime commented 1 year ago

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.

skaller commented 1 year ago

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

razetime commented 1 year ago

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: @.***>

skaller commented 1 year ago

Sure!

jlp765 commented 1 year ago

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;
}
skaller commented 1 year ago

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.