Kilde-til-kilde kodeoversetting frå CoffeeScript ved hjelp av AI involverer å bruke teknikkar for naturleg språkbehandling (NLP) og maskinlæringsalgoritmar for å analysere og forstå kildekode
Utfordringsbeskriving | CoffeeScript Syntaks Eksempel | VBScript Syntaks Eksempel | Poeng (1-10) |
---|---|---|---|
Funksjonsdeklarasjon | square = (x) -> x * x |
Function square(x) square = x * x End Function |
6 |
Listekomprehensjon | [x * x for x in [1..5]] |
Dim squares(5) For i = 1 To 5 squares(i) = i * i Next |
7 |
Implisitte returverdiar | double = (x) -> x * 2 |
Function double(x) double = x * 2 End Function |
5 |
Klasse-definisjon | class Animal constructor: (name) -> @name = name |
Class Animal Public Sub Class_Initialize(name) Me.name = name End Sub |
8 |
Splat-operator | args = (a, b...) -> a + b.length |
Function args(a, ParamArray b()) Return a + UBound(b) + 1 End Function |
7 |
Strenginterpolasjon | "Hello, #{name}" |
name = "World" msg = "Hello, " & name |
4 |
Standardparametrar | greet = (name = "stranger") -> "Hello, #{name}" |
Function greet(Optional name) If IsMissing(name) Then name = "stranger" greet = "Hello, " & name End Function |
6 |
Array-destrukturering | [first, second] = [1, 2] |
first = 1: second = 2 |
5 |
Fette pil-funksjonar | add = (a, b) => a + b |
Function add(a, b) add = a + b End Function |
6 |
Kjede av metodekall | array.map(x => x * 2).filter(x => x > 5) |
Dim result() For Each x In array If x * 2 > 5 Then result = AddToArray(result, x * 2) Next |
8 |
square = (x) -> x * x
Function square(x)
square = x * x
End Function
Referanse: CoffeeScript Funksjonar | VBScript Funksjonar
squares = [x * x for x in [1..5]]
Dim squares(5)
For i = 1 To 5
squares(i) = i * i
Next
Referanse: CoffeeScript Listekomprehensjonar | VBScript Array
double = (x) -> x * 2
Function double(x)
double = x * 2
End Function
Referanse: CoffeeScript Funksjonar | VBScript Funksjonar
class Animal
constructor: (name) -> @name = name
Class Animal
Public Sub Class_Initialize(name)
Me.name = name
End Sub
End Class
Referanse: CoffeeScript Klasser | VBScript Klasser
args = (a, b...) -> a + b.length
Function args(a, ParamArray b())
Return a + UBound(b) + 1
End Function
Referanse: CoffeeScript Splat-operator | VBScript ParamArray
msg = "Hello, #{name}"
name = "World"
msg = "Hello, " & name
Referanse: CoffeeScript Strenginterpolasjon | VBScript Strengsammensetting
greet = (name = "stranger") -> "Hello, #{name}"
Function greet(Optional name)
If IsMissing(name) Then name = "stranger"
greet = "Hello, " & name
End Function
Referanse: CoffeeScript Standardparametrar | VBScript Valfrie parametrar
[first, second] = [1, 2]
first = 1
second = 2
Referanse: CoffeeScript Array-destrukturering | VBScript Variablar
add = (a, b) => a + b
Function add(a, b)
add = a + b
End Function
Referanse: CoffeeScript Fette pil-funksjonar | VBScript Funksjonar
result = array.map(x => x * 2).filter(x => x > 5)
Dim result()
For Each x In array
If x * 2 > 5 Then
result = AddToArray(result, x * 2)
End If
Next
Referanse: CoffeeScript Kjede av kall | VBScript Løkker