How to transpose within a scale?

Hi, here's a beginner's question. I'm trying to figure out how to transpose a melodic sequence while staying within a scale -- using a "root note". Having looked around the reference and forums for a recipe, I just can't seem to find any (or, anything I'm able to understand).

For example, how do you turn this

once $ n "c d e f e d c" # sound "midi"

into this (transposing from c to d within c major)?

once $ n "d e f g f e d" # sound "midi"

An ideal solution would of course use scale -- so one could say things like, "play melodic sequence x using the D minor scale, starting each time from notes in sequence y".

Yes, scale is useful here, you can do something like:

tidal> n (scale "major" "0 1 2 3 2 1 0")
  (0>⅐)|n: 0.0n (c5)
 (⅐>²₇)|n: 2.0n (d5)
(²₇>³₇)|n: 4.0n (e5)
(³₇>⁴₇)|n: 5.0n (f5)
(⁴₇>⁵₇)|n: 4.0n (e5)
(⁵₇>⁶₇)|n: 2.0n (d5)
 (⁶₇>1)|n: 0.0n (c5)
tidal> n (scale "major" $ "0 1 2 3 2 1 0" + 1)
  (0>⅐)|n: 2.0n (d5)
 (⅐>²₇)|n: 4.0n (e5)
(²₇>³₇)|n: 5.0n (f5)
(³₇>⁴₇)|n: 7.0n (g5)
(⁴₇>⁵₇)|n: 5.0n (f5)
(⁵₇>⁶₇)|n: 4.0n (e5)
 (⁶₇>1)|n: 2.0n (d5)

Thanks a million, this was the help I needed! It's satisfying to see that this goes up the C major scale:

d4 $ fast 2 $ n (scale "major" $ "0 1 [2 3]" + "<0 4>") # sound "midi"

(And I could mention that the meaning of numbers and letters had me confused -- for example, that 4 here means the fifth note in the scale.)

I should add that I have also been scratching my head over how to select the key, and proudly display the following (using this post), going to D3:

d4 $ fast 2 $ n (scale "major" $ "0 1 [2 3]" + "<0 4>") |+ n "d3" # sound "midi"

Looking at this, wouldn't it would be more convenient to have a variant of scale that accepted the key as an argument?