KX Community

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

Home Forums kdb+ My guitar homework

  • My guitar homework

    Posted by SJT on February 2, 2023 at 12:00 am

    Q derives from the mathematical notation Ken Iverson developed at Harvard. Years before, when Ken was a young man in Alberta, a farmer he worked for asked him if he knew how to use a certain tool. Ken didnt. Well, said the farmer, you wont learn it younger.

    Amending past folly, Ive hired someone to teach me guitar at last. Part of my homework is to map notes to the frets on the guitar neck. Heres my assignment. Can you complete it as a single expression in q?

     

     

    SJT replied 8 months, 1 week ago 3 Members · 3 Replies
  • 3 Replies
  • cillianreilly

    Member
    February 2, 2023 at 12:00 am
    q)progression:"C#D#EF#G#A#B" 
    q)notes:flip progression mod[;12]til[13]+/:progression? 
    q)notes
    "EADGBE" 
    "EADGBE" 
    "F###CF" 
    "#BEA##" 
    "GCF#DG" 
    "###B##" 
    "ADGCEA" 
    "####F#" 
    "BEAD#B" 
    "CF##GC" 
    "##BE##" 
    "DGCFAD" 
    "######" 
    "EADGBE"

    First row is the open strings, and runs as far as the 12th fret, at which point the pattern repeats. Also works for alternative tunings:

    q)notes”DADGBE” // Drop D

    q)notes”DADGAD” // DADGAD

  • SJT

    Member
    March 2, 2023 at 12:00 am

    Love the train of unaries,  !

    My teacher made something of C# also being D?, so

     

    q)note:{flip(x?`$'y)rotate:x}[`$"`"vs"C`C#|Db`D`D#|Eb`E`F`F#|Gb`G`G#|Ab`A`A#|Bb`B"] 
    q)note 
    "EADGBE" E A D G B E F A#|Bb D#|Eb G#|Ab C F F#|Gb B E A C#|Db F#|Gb G C F A#|Bb D G G#|Ab C#|Db F#|Gb B D#|Eb G#|Ab A D G C E A A#|Bb D#|Eb G#|Ab C#|Db F A#|Bb B E A D F#|Gb B C F A#|Bb D#|Eb G C C#|Db F#|Gb B E G#|Ab C#|Db D G C F A D D#|Eb G#|Ab C#|Db F#|Gb A#|Bb D#|Eb

     

     

  • 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.

Log in to reply.