mirror of
https://github.com/catppuccin/catppuccin
synced 2024-11-23 03:53:04 +00:00
chore: add R and Swift syntax samples
This commit is contained in:
parent
ba66c8aa34
commit
c9b85c2d60
2 changed files with 83 additions and 0 deletions
21
samples/r.r
Normal file
21
samples/r.r
Normal file
|
@ -0,0 +1,21 @@
|
|||
# function declaration
|
||||
global_function <- function(regular, named = "Hello World!") {
|
||||
# inner function declaration
|
||||
inner_function <- function() {
|
||||
closure_usage <- regular
|
||||
closure_usage + 1
|
||||
}
|
||||
|
||||
print(named)
|
||||
regular + inner_function()
|
||||
}
|
||||
|
||||
# function call
|
||||
global_function(2, named = 'Hello World!')
|
||||
|
||||
cat = list(name = "Smudge", breed = "Maine Coon")
|
||||
#variable acсess
|
||||
print(cat$breed)
|
||||
|
||||
# namespace access
|
||||
print(datasets::cars[1, 2])
|
62
samples/swift.swift
Normal file
62
samples/swift.swift
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/swift
|
||||
/*
|
||||
Block comment
|
||||
*/
|
||||
import Cocoa // line comment
|
||||
|
||||
actor ActorName { var s: [StructName?] }
|
||||
struct StructName { var s: [StructName?] }
|
||||
enum EnumName { case Foo, Bar }
|
||||
protocol ProtocolName {
|
||||
associatedtype AssociatedType
|
||||
var p: ProtocolName { get set }
|
||||
var prop: AssociatedType { get }
|
||||
}
|
||||
typealias TypeAlias = EnumName
|
||||
@attr(arg, *)
|
||||
class ClassName<T> : ProtocolName {
|
||||
var property : ClassName
|
||||
var t : T
|
||||
func method(p: TypeAlias) {
|
||||
let c = ClassName(),
|
||||
tuple: (key: String, value: Int) = (key: 0, value: 1)
|
||||
self.property = c != nil ? c! : t
|
||||
}
|
||||
let prop: String
|
||||
}
|
||||
|
||||
extension ClassName { }
|
||||
extension StructName { }
|
||||
|
||||
let i: Int = (2 + 2) * 2;
|
||||
let _ = { $0 }
|
||||
let _ = { p in p }
|
||||
let e = EnumName.Foo;
|
||||
switch e {
|
||||
case .Foo: print("foo\n")
|
||||
default: print("""
|
||||
no foo \u{1F596}
|
||||
""")
|
||||
}
|
||||
|
||||
func function<T>(externalName paramName : T) throws {
|
||||
func nestedFunc() { }
|
||||
nestedFunc()
|
||||
function(externalName: paramName + 1)
|
||||
throw NSError()
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
print("debug")
|
||||
#else
|
||||
print("nodebug")
|
||||
#endif
|
||||
#if swift(>=3.0)
|
||||
print("conditionally not parsed code")
|
||||
#endif
|
||||
|
||||
/// Doc comment
|
||||
/// - Parameter paramName:
|
||||
/// - Returns: value
|
||||
/// - Throws: description
|
||||
foo(paramName: Int) throws -> Int { 0 }
|
Loading…
Reference in a new issue