[48in24 Exercise] [02-20] List Ops

This issue is a discussion for contributors to collaborate in getting ready to be featured in 48in24. Please refer to this forum topic for more info.


We will be featuring List Ops from Feb 20 onwards.

Staff jobs

These are things for Erik/Jeremy to do:

  • ☐ Check/update exercise in Problem Specifications
  • :ballot_box_with_check: Create + schedule video

Community jobs

For each track:

  • Implement List Ops
  • Add approaches (and an approaches introduction!) for each idiomatic or interesting/educational approach.
  • Add video walkthroughs (record yourself solving and digging deeper into the exercise).
  • Highlight up to 16 different featured exercises (coming soon)

Existing Approaches

You can use these as the basis for approaches on your own tracks. Feel free to copy/paste/reuse/rewrite/etc as you see fit! Maybe ask ChatGPT to translate to your programming language.

Track Statuses

You can see an overview of which tracks have implemented the exercise at the #48in24 implementation status page.

The Rust track has accumulate implemented, but not list-ops. Should I implement list-ops and deprecate accumulate? Given that accumulate was deprecated in favor of list-ops, I suppose it doesn’t make sense to have both.

Your choice basically. Some tracks have done that, but track maintainers have to decide for themselves whether it makes sense for their track. As an example, I’ve not deprecated accumulate in C# and F#, as it makes for a very focused exercise to help teach yield respectively recursion.

1 Like

I’ll port for Ballerina, CFML, Groovy, and Red.

1 Like

This is certainly an interesting exercise in bash. Functions in bash typically receive arguments by value, but arrays are harder to pass by value: you can stringify the array, but choosing a separator that doesn’t appear also in the data can be challenging. The array name can be passed to the function and some pretty horrific string manipulation can be done to make a copy of the array elements.

bash v4 introduced “namerefs” where you’d pass the array name to a function and in the function, that parameter is declared as a reference.

incr() { local -n var=$1; ((var++)); return; }
x=5
incr x
echo $x    # => 6

and an array example

prepend() { local -n ary=$1; ary=( "${@:2}" "${ary[@]}" ); }
a=(11 22 33)
prepend a 44 55
echo "${a[*]}"   # => 44 55 11 22 33

This is kind of an esoteric concept to explain in a couple of minutes in a video, perhaps. I wanted to highlight bash for this exercise because it is the first one in bash where the solution is not a standalone script, but a library of functions. Apart from namerefs, the solutions are not particularly notable.

2 Likes

Approaches in process for Python.

1 Like

I’ll see if I can try and explain this well. Would glennj's solution for List Ops in Bash on Exercism be your preferred idiomatic solution?

I think so.

PR for adding the exercise to the LFE track: Add list-ops exercise by kahgoh · Pull Request #196 · exercism/lfe · GitHub

1 Like

Done:

Have you done Groovy yet? I can take if not.

@glennj, feel free. I haven’t had any time this week to work on list ops.

Catching up on this. Ballerina and CFML are almost ready, but I’m a little stuck on Red so that’ll take a few more days.

1 Like
1 Like
1 Like

I’ll work on this for D next week.

1 Like
1 Like
2 Likes