• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

MacGap programming help

calebprime

Penultimate Amazing
Joined
Jul 5, 2006
Messages
13,001
Anyone familiar with MacGap, an application for number theory on the Macintosh?

I don't know much about programming, but I can take simple code and adapt it for my purposes. This saves time over doing things by hand.

It would be useful to have some code that will do "mappings". This just means, given some input string of numbers, substitute particular numbers for those numbers.

example: "map 35"

for the numbers 0,1,2,3,4,5,6,7,8,9,10,11
substitute
0,2,5,7,10,1,4,8,11,3,6,9

so, given 5,3,6,1,9,4,0,11,7,8,10,2
the answer is:
1,7,4,2,3,10,0,9,8,11,6,5

I take code and paste it into MacGap. It's a duffer's approach, but it works for me.

like so:

gap> for i in [5,3,6,1,9,4,0,11,7,8,10,2] do
> Print(i, " multiplied mod 13 " , ((i-8) mod 12 *2) mod 13,"\n"); od;
5 multiplied mod 13 5
3 multiplied mod 13 1
6 multiplied mod 13 7
1 multiplied mod 13 10
9 multiplied mod 13 2
4 multiplied mod 13 3
0 multiplied mod 13 8
11 multiplied mod 13 6
7 multiplied mod 13 9
8 multiplied mod 13 0
10 multiplied mod 13 4
2 multiplied mod 13 12

this takes a series, tranposes it down 8 semitones, and multiplies it by 2 mod 13.

So, I'm looking for simple code something like this where I can make a few changes and plug it into MacGap.
 
Last edited:
maybe I haven't had enough coffee yet, but isn't that already GAP code that you have there?
 
Hi Terry,

Yes, it was just an example of what I can already do--which isn't much, but it's already better than working by hand.

Sorry for the confusion. What I provided was just an example of adapting some simple bit of code for my purposes.

It wasn't the code that does what I want to be able to do.

It was intended to show the very basic level I'm working at, and what the code I'm looking for would look like.

Because I'm neither a mathematician nor a programmer, I find little things I can use that seem to make life easier.

eta: I want to be able to do "mappings" with Gap as I described. The example I provided is just a modular multiplication with a transposition.
 
Last edited:
This can be done with almost any word processor, but for some reason I was wondering how to do it with Gap.
 
for the numbers 0,1,2,3,4,5,6,7,8,9,10,11
substitute
0,2,5,7,10,1,4,8,11,3,6,9

so, given 5,3,6,1,9,4,0,11,7,8,10,2
the answer is:
1,7,4,2,3,10,0,9,8,11,6,5

I think this would work:

x := [0,2,5,7,10,1,4,8,11,3,6,9];;
for i in [5,3,6,1,9,4,0,11,7,8,10,2] do Print(x[i + 1], ","); od;

(Well, almost. You'll get an unneeded comma at the end...)
 
I think this would work:

x := [0,2,5,7,10,1,4,8,11,3,6,9];;
for i in [5,3,6,1,9,4,0,11,7,8,10,2] do Print(x[i + 1], ","); od;

(Well, almost. You'll get an unneeded comma at the end...)

:)

It does indeed work, right off the bat.

Thanks once again, 69dodge!

Using Mac Gap for my immoral porpoises is like using an autoclave to make coffee...
 
Somewhat to my surprise, this little bit of code turns out to be useful. Something more elaborate would have saved me hundreds of copy-and-pastes, but this alone turns out to be much faster than using a word processor or doing it by hand. I end up with a list of series that gradually, imperfectly "expand".

F#,E,G,D,Bb,F,C,C#,G#,A,B,Eb,
G,F,G#,D,B,F#,C,Eb,A,Bb,C#,E,
G,F,G#,C#,B,F#,C,Eb,A,Bb,D,E,
G#,F#,A,D,C#,G,C,F,Bb,B,Eb,E,
A,F#,Bb,D,Eb,G#,C,G,B,C#,F,E,
A,F,Bb,C#,Eb,G#,C,G,B,D,F#,E,
G#,F,Bb,D,Eb,G,C,A,B,C#,F#,E,

G#,F,Bb,D,E,G,C,A,B,C#,F#,Eb,
G#,F,Bb,C#,E,G,C,A,B,D,F#,Eb,
G#,E,Bb,C#,F,G,C,A,B,D,F#,Eb,
G#,F,Bb,C#,E,F#,C,A,B,D,G,Eb,
Bb,F#,B,D,F,G#,C,A,C#,Eb,G,E,
Bb,F#,B,C#,F,G#,C,A,D,E,G,Eb,
Bb,F,B,D,F#,G#,C,A,C#,E,G,Eb,
G,E,Bb,C#,F,F#,C,A,B,D,G#,Eb,

Bb,F#,B,C#,F,G,C,A,D,E,G#,Eb,
Bb,F,B,C#,F#,G,C,A,D,E,G#,Eb,
B,G,D,Eb,G#,A,C,C#,E,F#,Bb,F,
B,G,D,Eb,A,G#,C,C#,F,F#,Bb,E,
C#,A,E,Eb,B,Bb,C,F,G,G#,D,F#,
C#,G#,E,Eb,B,Bb,C,F,G,A,D,F#,
C#,G#,E,Eb,B,Bb,C,G,F#,A,D,F,
D,A,F,Eb,C#,B,C,G,G#,Bb,E,F#,
B,G,Eb,D,C#,A,C,G#,F#,Bb,F,E,
B,F#,Eb,D,C#,A,C,G#,G,Bb,F,E,
C#,G,F,D,Eb,Bb,C,G#,A,B,F#,E,
Eb,G,F#,D,C#,Bb,C,A,G#,B,E,F,
Eb,G,G#,D,B,Bb,C,A,C#,F#,E,F,

etc.
 

Back
Top Bottom