Skip to content

Commit 4dad4e3

Browse files
authored
Add R (#770)
* Add R * uncomment languages in dev.Dockerfile
1 parent de04099 commit 4dad4e3

File tree

9 files changed

+67
-1
lines changed

9 files changed

+67
-1
lines changed

config/langs.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,25 @@ for arg in sys.argv[1:]:
749749
print(arg)
750750
'''
751751

752+
[R]
753+
size = '83.1 MiB'
754+
version = '4.2.1'
755+
website = 'https://www.r-project.org'
756+
example = '''
757+
# Printing
758+
write("Hello, World!", 1)
759+
760+
# Looping
761+
for (i in 0:9) {
762+
write(i, 1)
763+
}
764+
765+
# Accessing arguments
766+
for (arg in commandArgs(TRUE)) {
767+
write(arg, 1)
768+
}
769+
'''
770+
752771
[Raku]
753772
size = '58.1 MiB'
754773
version = 'Raku 6.d on Rakudo 2022.12'

db/a-schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CREATE TYPE lang AS ENUM (
5555
'crystal', 'd', 'dart', 'elixir', 'f-sharp', 'fish', 'fortran', 'go',
5656
'golfscript', 'haskell', 'hexagony', 'j', 'java', 'javascript', 'julia',
5757
'k', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php', 'powershell',
58-
'prolog', 'python', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift', 'tcl',
58+
'prolog', 'python', 'r', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift', 'tcl',
5959
'v', 'viml', 'wren', 'zig'
6060
);
6161

docker/dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 146 M
2222
COPY --from=codegolf/lang-f-sharp ["/", "/langs/f-sharp/rootfs/" ] # 135 MiB
2323
COPY --from=codegolf/lang-cpp ["/", "/langs/cpp/rootfs/" ] # 118 MiB
2424
COPY --from=codegolf/lang-fortran ["/", "/langs/fortran/rootfs/" ] # 85.6 MiB
25+
COPY --from=codegolf/lang-r ["/", "/langs/r/rootfs/" ] # 83.1 MiB
2526
COPY --from=codegolf/lang-assembly ["/", "/langs/assembly/rootfs/" ] # 79.9 MiB
2627
COPY --from=codegolf/lang-python ["/", "/langs/python/rootfs/" ] # 74.1 MiB
2728
COPY --from=codegolf/lang-raku ["/", "/langs/raku/rootfs/" ] # 58.1 MiB

docker/live.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 146 M
3535
COPY --from=codegolf/lang-f-sharp ["/", "/langs/f-sharp/rootfs/" ] # 135 MiB
3636
COPY --from=codegolf/lang-cpp ["/", "/langs/cpp/rootfs/" ] # 118 MiB
3737
COPY --from=codegolf/lang-fortran ["/", "/langs/fortran/rootfs/" ] # 85.6 MiB
38+
COPY --from=codegolf/lang-r ["/", "/langs/r/rootfs/" ] # 83.1 MiB
3839
COPY --from=codegolf/lang-assembly ["/", "/langs/assembly/rootfs/" ] # 79.9 MiB
3940
COPY --from=codegolf/lang-python ["/", "/langs/python/rootfs/" ] # 74.1 MiB
4041
COPY --from=codegolf/lang-raku ["/", "/langs/raku/rootfs/" ] # 58.1 MiB

hole/play.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ func play(ctx context.Context, holeID, langID, code string, score *Scorecard) {
253253
case "python":
254254
// Force the stdout and stderr streams to be unbuffered.
255255
cmd.Args = []string{"/usr/bin/python", "-u", "-"}
256+
case "r":
257+
cmd.Args = []string{"/usr/bin/Rscript", "-"}
256258
case "sed":
257259
cmd.Args = []string{"/usr/bin/sed", "-E", "-z", "--sandbox", "-u", "--", code}
258260
case "swift":

js/_codemirror.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { powerShell } from '@codemirror/legacy-modes/mode/powershell';
4545
import { prolog } from 'codemirror-lang-prolog';
4646
import { python } from '@codemirror/lang-python';
4747
import { raku } from './vendor/codemirror-raku';
48+
import { r } from '@codemirror/legacy-modes/mode/r';
4849
import { ruby } from '@codemirror/legacy-modes/mode/ruby';
4950
import { rust } from '@codemirror/lang-rust';
5051
import { shell } from '@codemirror/legacy-modes/mode/shell';
@@ -136,6 +137,7 @@ export const extensions = {
136137
'powershell': StreamLanguage.define(powerShell),
137138
'prolog': prolog(),
138139
'python': python(),
140+
'r': StreamLanguage.define(r),
139141
'raku': StreamLanguage.define(raku),
140142
'ruby': StreamLanguage.define(ruby),
141143
'rust': rust(),

langs/r/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM alpine:3.16 as builder
2+
3+
RUN apk add --no-cache R
4+
5+
FROM codegolf/lang-base
6+
7+
COPY --from=0 /lib/ld-musl-x86_64.so.1 \
8+
/lib/libz.so.1 /lib/
9+
COPY --from=0 /bin/sed \
10+
/bin/mkdir \
11+
/bin/uname \
12+
/bin/rm \
13+
/bin/sh /bin/
14+
COPY --from=0 /usr/bin/Rscript \
15+
/usr/bin/R /usr/bin/
16+
COPY --from=0 /usr/lib/R /usr/lib/R
17+
COPY --from=0 /usr/lib/libopenblas.so.3 \
18+
/usr/lib/libpcre2-8.so.0 \
19+
/usr/lib/liblzma.so.5 \
20+
/usr/lib/libbz2.so.1 \
21+
/usr/lib/libicuuc.so.71 \
22+
/usr/lib/libicui18n.so.71 \
23+
/usr/lib/libgomp.so.1 \
24+
/usr/lib/libgfortran.so.5 \
25+
/usr/lib/libncursesw.so.6 \
26+
/usr/lib/libicudata.so.71 \
27+
/usr/lib/libstdc++.so.6 \
28+
/usr/lib/libgcc_s.so.1 \
29+
/usr/lib/libquadmath.so.0 \
30+
/usr/lib/libreadline.so.8 /usr/lib/
31+
COPY --from=0 /etc/R /etc/R
32+
RUN mkdir /root
33+
34+
ENTRYPOINT ["Rscript"]
35+
36+
CMD ["-e", "commandArgs()"]

latest-langs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ constant @urls = (
2929
'PowerShell' => 'PowerShell',
3030
'Prolog' => 'SWI-Prolog',
3131
'Python' => 'Python_(programming_language)',
32+
'R' => 'R_(programming_language)',
3233
'Raku' => 'Rakudo',
3334
'Ruby' => 'Ruby_(programming_language)',
3435
'Rust' => 'Rust_(programming_language)',

svg/r.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)