g | x | w | all
Bytes Lang Time Link
071tinylisp250206T080100ZMukundan
8875Vyxal230603T115903Zlyxal
020Japt h210326T103704ZAZTECCO
017Vyxal210608T042201Zemanresu
086Racket210325T182905Zhyperneu
104Common Lisp210328T032153ZASCII-on
100Lua210326T174438Zval - di
009Jelly210325T150326Zcaird co
057Factor210326T000504Zchunes
054Python 3210326T061513Zkops
075Python 3210325T152937ZDelfad0r
048JavaScript V8210325T152655Zuser8165
035J210325T231111ZJonah
073Retina 0.8.2210325T233257ZNeil
020Charcoal210325T231100ZNeil
069Jq210325T194909ZWezl
017Pyth210325T171342Zhakr14
010Stax210325T155519ZRazetime
060Scala210325T151402Zuser
072JavaScript V8210325T145519Zrydwolf
086Python 3210325T145358Zhyperneu

tinylisp, 71 bytes

(d F(q((A L)(i(t A)((i(e(h A)97)h t)(F(t A)L))L
(q((L S)(F(t(chars S))L

Try it online!

(q((L S)(F(t(chars S))L    # anonmyous lambda
   (L S)                   #   args L (list), S (accessor as string)
        (                  #   return
         F                 #     F(
          (t(chars S))     #       S[1:] converted to ascii values,
                      L    #       L
                           #     )


(d F(q((A L)(i(t A)((i(e(h A)97)h t)(F(t A)L))L
(d F                                             # F = lambda
       (A L)                                     # args A (accessor as ascii values), L (list)
             i(t A)                              #   if A has more than 1 element:
                                    (F(t A)L)    #     F(A[1:], L)
                     i(e(h A)97)                 #     if A[0] == 97:
                                h                #        take first element of recursive call
                                  t              #     else: remove first element of recursive call
                                              L  #   else: return L as is

Vyxal, 71 bitsv2, 8.875 bytes

ḢṪṘ(₍ḢhnAi

Try it Online!

Explained

ḢṪṘ(₍ḢhnAi
ḢṪ         # Remove the c and r from the input
  Ṙ        # and reverse it
   (       # for each char
    ₍Ḣh    #   [top_of_stack[1:], top_of_stack[0]]
         i #   indexed by
       nA  #   is char a vowel?

Japt -h, 20 bytes

VÔkric)¬£=X¥'a?UÎ:UÅ

Try it

    1st input U = data
    2nd input V = command
    
    VÔk"cr" - reverse and remove 'cr'
    £ ... Ã - pass each remaining letters to :
    =         - reassign 1st input(U)
    X¥'a?UÎ   - 1st item if 'a'
    :UÅÃ      - else the rest
    -h flag to output result 

Vyxal, 17 bytes

£ḢṪṘƛ\a=[&h|&Ḣ];¥

Try it Online!

A mess :P

Racket, 86 bytes

(λ(a c)(foldr(λ(c a)(case c[(#\a)(car a)][(#\d)(cdr a)][else a]))a(string->list c)))

Try it online!

-3 bytes thanks to Wezl
-73 bytes thanks to ASCII-only
-8 bytes thanks to MLavrentyev

Input in the format (f <data> <string>)

Of course there has to be a lisp/scheme/racket/whatever answer :P

This is probably pretty bad because it's my first time golfing in Racket. I just know what I was taught in my basic first-year CS courses :P

Common Lisp, 106 104 bytes

(lambda(a c)(reduce(lambda(a c)(if(eq c #\a)(car a)(if(eq c #\d)(cdr a)a)))(reverse c):initial-value a))

Try it online!

Direct port of the racket answer.

Lua, 100 bytes

load[[t,c=...c:reverse():gsub('[ad]',load"if...=='a'then t=t[1]else table.remove(t,1)end")return t]]

Try it online!

Function that accepts a nested table structure and a string. I sure would be impressed to see this golfed further. Please note that original table structure will be modified when using d command, so don't pass it there if it have value to you (or, better yet, never use this code outside of TIO sandbox).

TIO link also includes a test suite.

Jelly, 11 9 bytes

Oị⁾ḢḊḊṖUv

Try it online!

-2 bytes thanks to Unrelated String!

Takes the accessor on the left and the array on the right

Oị⁾ḢḊḊṖUv - Main link. Accessor A on left, Array L on right
O         - Convert A to ordinals. Note that 'a' is odd and 'd' is even
 ị⁾ḢḊ     - Index into "ḢḊ". Odd characters yield "Ḣ" and even "Ḋ"
     ḊṖ   - Remove first and last values from A
       U  - Reverse
        v - Evaluate as Jelly code, with L as the argument

is the head command, which returns the first element of a list. is the dequeue command, which removes the first element of a list. The code executed by v is just a series of and atoms, which perform one after another.

Factor, 61 57 bytes

[ rest reverse rest [ 97 = [ first ] [ rest ] if ] each ]

Try it online!

-4 bytes thanks to @Neil!

Explanation:

This is a quotation (anonymous function) that takes two sequences from the data stack and leaves one sequence on the data stack. In Factor, strings are just sequences of unicode code points and can be manipulated like any other sequence.

Python 3, 68 66 54 bytes

lambda r,s:eval(s[:0:-1].translate(["[1:]","[0]"]*51))

Try it online!

Alt, similar idea (which works in Python 2):

Python 3, 68 66 bytes

lambda l,c:eval(l+''.join("[[10:]]"[x<'d'::2]for x in c[-2:0:-1]))

Try it online!

Both create an eval string which just appends the desired sequence of subscripts/slices directly to the list, with the first one using the added trick of keeping the "r" as the list name. The first one takes an actual list as input and the second takes a string representation of a list.

Credit to xnor for pointing me at translate() and the idea of using r as the list name for -12 bytes!

Python 3, 80 79 75 bytes

f=lambda s,x:eval(['%s[1:]','%s[0]','x#%s','%s'][ord(s[0])%4]%'f(s[1:],x)')

Try it online!

By sheer luck, ord(s[0])%4 is able to distinguish between a, c, d, r.

JavaScript (V8), 48 bytes

a=>f=b=>b[2]?b[[x,...r]=f(b.slice(1)),1]<f?x:r:a

Try it online!

-2 bytes thanks to @Arnauld!

J, 35 bytes

4 :0
".'y',~(}.}:x)rplc;:'a{.d}.'
)

Try it online!

Note: -3 off TIO count for f=:

Retina 0.8.2, 73 bytes

+`(a|(d))r.(((\[)|(?<-5>])|\d|(?(5),))+),?(?(2)(?<3>.*)|.*)
r$#2$*[$3
cr

Try it online! Link includes test cases. Explanation:

+`

Repeat until a match cannot be made.

(a|(d))r.(((\[)|(?<-5>])|\d|(?(5),))+),?(?(2)(?<3>.*)|.*)

Match either an a or d (remembering which), then an implied [, then a sequence of [s, ]s, ,s and digits, except no more ]s than [s and only matching ,s between [s and ]s, then an optional ,, then if it was a d that matched then replace the match of the first term with the tail of the list otherwise just delete the tail.

r$#2$*[$3

Keep the r, re-insert the [ if the d was matched, and insert the first term or tail as matched above.

cr

Finally delete the remaining cr.

Charcoal, 20 bytes

F⮌η≡ιa≔§θ⁰θd≔ΦθλθcIθ

Try it online! Link is to verbose version of code. Outputs using Charcoal's default format, which is each array element on its own line and each subarray double-spaced from the next (+1 byte to output in Python str format). Explanation:

F⮌η≡ι

Loop over the command characters in reverse order and switch on them.

a≔§θ⁰θ

For a replace the input with its first element.

d≔Φθλθ

For d filter the first element from the input.

cIθ

For c print the result.

Jq, 69 bytes

Takes an object with keys "c" for the accessor and "l" for the list.

reduce((.c/"")[1:-1]|reverse[])as$c(.l;if$c=="d"then.[1:]else.[0]end)

Explanation

reduce        $0               as$c($1;             $2              )
  # the accumulator starts at $1. For each $0 (stored as the variable $c),
  # it becomes the result of $2 applied to it.
      ((.c/"")[1:-1]|reverse[])
  # the command (.c), split (/""), with the ends snapped ([1:-1])
  # reversed (reverse), every value inside this array  ([])
                                    .l;if$c=="d"then.[1:]else.[0]end
  # starting with the list (.l), if the character is "d" then the list
  # becomes its tail (.[1:]), otherwise its head (.[0]).

Jq play it!

Run test cases

Pyth, 17 bytes

.v+PtXQ"da""th"\E

Test suite

Uses pretty much the same approach as ChartZ Belatedly's Jelly answer.


As an aside, this answer could shed 3/4 bytes if Pyth had an 'evaluate with argument' builtin, and an additional 1/2 if it had Jelly's 'transliterate' (Pyth builtins can be one or two bytes). This would put it at 11/12/13 bytes, which at best ties the 11 bytes Jelly takes. This is especially impressive since Jelly has to reverse the accessor, while Pyth doesn't (Pyth uses reverse Polish notation).

Stax, 10 bytes

Ç≈≡ø*fáì☺○

Run and debug it

Returns a string of codepoints if array, and number if it's a number. The code can be verified here: Try it

Explanation

"ahdD"|trDl
"ahdD"|t    translate 'a' to 'h' and 'd'  to 'D'
        r   reverse
         D  delete first element
          l eval

checking code:
cc|4{|u}a?
cc         dup twice
  |4     ? if it's an array:
    {|u}   convert to JSON
        a  otherwise leave as is

Scala, 60 bytes

_.tail.init.:\(_){case(x,m:Seq[_])=>if(x<98)m(0)else m.tail}

Try it in Scastie!

I hate nested lists. Because of them, we need a pattern matching function (or casts, which are longer).

_                            //The command ("caadddaddaar")
  .tail                      //Drop the 'c'
  .init                      //Drop the 'r'
.:\                          //Fold right the "aadddada"
  (_)                        //Starting with the inputted list
  {                          //Pattern matching function literal
    case (x, m: Seq[_]) =>   //The command is x, the list is m (must be a Seq)
    if (x < 98) m(0)         //If the command is 'a', return the first element
    else m.tail              //Else, drop the first element
  }

JavaScript (V8), 77 72 bytes

c=>d=>[...c.slice(1)].reverse(d=[d]).map(n=>d=n=="d"?d.slice(1):d[0])&&d

Turns out the boring solution wins

JavaScript (V8), 91 90 87 84 bytes

c=>d=>[...c.slice(1)].map(n=>x=>n=="d"?x.slice(1):x[0]).reduceRight((a,f)=>f(a),[d])

Can't add a TIO link on school WiFi :/

Explanation:

This is a cool approach, using functional stuff. It slices the command name to remove the c, splits it into characters, then maps them to functions:

My current approach actually returns one function, which can still access the n variable, which saves three bytes. I don't really know how to explain it but it works :p

It then uses reduceRight to apply those functions in reverse order, on [d]. This saves a byte over my old approach, which also sliced off the r.

Python 3, 86 bytes

lambda l,c,a=lambda x:x[0],d=lambda x:x[1:]:eval("(".join(d(c))[:-1]+l+")"*(len(c)-2))

Try it online!

-1 byte thanks to @Stephen