Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Advanced Programming
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Job Cuppen
Advanced Programming
Commits
26fee0d8
Commit
26fee0d8
authored
Sep 09, 2019
by
Job Cuppen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added answers for drop shift1 rotate1 and tile
parent
522b4975
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
12 deletions
+75
-12
week01/answers.md
week01/answers.md
+18
-1
week01/ex7.sac
week01/ex7.sac
+57
-11
No files found.
week01/answers.md
View file @
26fee0d8
...
...
@@ -172,6 +172,23 @@ compilation failed while Running type inference system, 1 error(s).
this is because
`reshape([1,1], [1])`
and
`reshape([1], [1])`
do not have the same dimensionality.
## Exercise 7
### a)
### a) drop
`take(-(shape(vec) - sv), vec)`
### b) tile
`take(sv, take(-(shape(vec) - ov), vec))`
### c) shift 1
`genarray(ov, expr) ++ take(shape(vec) - ov;, vec)`
### d) shift 2
???
### e) rotate 1
`take(-ov, vec) ++ take((shape(vec) - ov), vec)`
### f) rotate 2
???
week01/ex7.sac
View file @
26fee0d8
...
...
@@ -4,22 +4,68 @@ use Array: all;
int main()
{
vec = [1,2,3,4,5,6];
sv = [1];
sv = [2,2];
ov = [2];
// vec = reshape([3,2], vec);
//a
printf("Drop as Take\n");
//
printf("Drop as Take\n");
// print(shape(vec));
// print(shape(vec) - sv);
d = drop(sv, vec); // [3,4,5,6,7]
t = take(-(shape(vec) - sv), vec); // [1,2]
// d = drop(sv, vec);
// td = take(-(shape(vec) - sv), vec);
print(d);
print(t
);
//
print(d);
// print(td
);
//b
// printf("Tile as Take\n");
return 0;
}
// t = tile(sv, ov, vec);
// ttd = take(sv, drop(ov, vec));
// tt = take(sv, take(-(shape(vec) - ov), vec));
// print(t);
// print(ttd);
// print(tt);
//c
// printf("Shift 1 as Take\n");
// expr = -1;
// s = shift(ov, expr, vec);
// st = genarray(ov, expr) ++ take(shape(vec) - ov;, vec);
// print(s);
// print(st);
//d
// printf("Shift 2 as Take\n");
// expr = -1;
// s = shift(ov, expr, vec);
// st = genarray(ov, expr) ++ take(sh, vec);
// [3,2] - [2] = [1]
\ No newline at end of file
// print(s);
// print(st);
//e
// printf("Rotate 1 as Take\n");
// r1 = rotate(ov, vec);
// r1t = take(-ov, vec) ++ take((shape(vec) - ov), vec);
// print(r1);
// print(r1t);
//f
// printf("Rotate 2 as Take\n");
// r2 = rotate(ov, vec);
// print(r2);
// print(r2t);
return 0;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment