KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ My guitar homework Re: My guitar homework

  • davidcrossey

    Member
    March 2, 2023 at 12:00 am

    Very nice  !
    Just to make your solution visually easier to read, I’ve casted to symbols:

    q)progression:`$("C";"C#";"D";"D#";"E";"F";"F#";"G";"G#";"A";"A#";"B") 
    q)notes:flip progression mod[;12]til[13]+/:progression? 
    q)notes `$'"EADGBE" 
    E A D G B E F A# D# G# C F F# B E A C# F# G C F A# D G G# C# F# B D# G# A D G C E A A# D# G# C# F A# B E A D F# B C F A# D# G C C# F# B E G# C# D G C F A D D# G# C# F# A# D# E A D G B E

    And to satisfy  for a one-liner, condensed as:

    {flip x mod[;12]til[13]+/:x?y}[`$(“C”;”C#”;”D”;”D#”;”E”;”F”;”F#”;”G”;”G#”;”A”;”A#”;”B”);`$'”EADGBE”]

    Look forward to seeing how others approach this problem.