Memuat Selamanya ... Gaya Windows

36

Buat bilah Memuat gaya Windows dengan instruksi berikut.

(perhatikan bahwa ini berbeda dari Memuat ... Selamanya )

Output Anda harus dimulai dengan [.... ].

Setiap centang, Anda harus menunggu 100 ms, lalu pindahkan setiap titik dengan satu karakter ke kanan. jika titik ada pada karakter kesepuluh, pindahkan ke yang pertama. Perhatikan bahwa Anda harus menghapus layar sebelum mengeluarkan lagi. Outputnya dipesan sebagai berikut:

[....      ]
[ ....     ]
[  ....    ]
[   ....   ]
[    ....  ]
[     .... ]
[      ....]
[.      ...]
[..      ..]
[...      .]

..Lalu itu loop selamanya.

Aturan

  • Ini , jadi jawaban tersingkat menang. Aku ragu aku bahkan akan menerima jawaban menang
  • Harap berikan file gif bilah pemuatan saat beraksi jika memungkinkan.
Matthew Roh
sumber
1
Bisakah kita mengeluarkan, katakanlah, dua puluh baris baru sebelum setiap keluaran untuk 'menghapus' layar?
Okx
2
@ OKK Ya, jika bahasa Anda tidak memiliki cara lain untuk membersihkan layar.
Matthew Roh
Berapa banyak kesalahan yang bisa ditunda? (Mis. + - 0,5 detik) Saya sarankan kesalahan 250 milidetik ....
stevefestl
1
Dapatkah saya menyarankan untuk tidak memasukkan penundaan waktu yang tetap pada tantangan di masa depan? Saya menemukan itu muncul di banyak tantangan baru-baru ini, dan setiap kali saya menulis boilerplate ungolfable yang sama untuk membuat sistem menunggu n milesekon.
xnor
2
Apakah penggunaan \rdiizinkan, alih-alih membersihkan layar secara harfiah?
phyrfox

Jawaban:

19

V, 17 16 15 byte

i[´.¶ ]<esc>ògó$X|p

<esc>adalah 0x1b.

Dan hexdump:

00000000: 695b b42e b620 5d1b f267 f324 587c 70    i[... ]..g.$X|p

Penjelasan

i                       " Insert
[                       " a [
´.                      " 4 .s
¶<space>                " 6 spaces
]<esc>                  " and a ]. Then return to normal mode
ò                       " Recursively do:
 gó                     "  Sleep for 100 milliseconds
 $                      "  Go to the ]
 X                      "  Delete the character to the left of the ]
 |                      "  Go to the [
 p                      "  And paste the deleted character right after the [
                        " Implicit ending ò

gif

Kritixi Lithos
sumber
Bagaimana cara menguji Vim?
Pavel
@Phoenix i.... <esc>qq:sl 100m<CR>$X|P@qq@qharus bekerja ( <esc>jelas kunci pelarian dan <CR>linefeed) (ada 6 spasi setelah 4 titik)
Kritixi Lithos
3
Senang melihat fungsinya bermanfaat. Jawaban bagus BTW :)
DJMcMayhem
19

CSS / HTML, 202 190 186 + 45 = 247 235 231 byte

pre{position:relative}x{position:absolute;display:inline-block;width:10ch;height:1em;overflow:hidden}x>x{width:14ch;left:-10ch;animation:1s steps(10,end)infinite l}@keyframes l{to{left:0
<pre>[<x><x>....      ....</x></x>          ]

Sunting: Disimpan 12 14 byte berkat @Luke.

Neil
sumber
Tidak bisakah Anda menyimpan 6 byte dengan mengubah nama animasi menjadi seperti ini b?
Lukas
@ Lukas Saya tidak percaya saya lupa melakukan itu ...
Neil
Anda dapat menyimpan 2 byte lebih banyak dengan menjatuhkannya chdi akhir; 0tidak membutuhkan unit.
Luke
2
Bagaimana dengan berubah <x>menjadi <span>(dan di dalam CSS juga: xmenjadi spandan x>xmenjadi span>*)? Itu menghemat display:inline-block;, tetapi biaya hanya 15 byte. Jadi total 6B disimpan.
Lukas
1
@ Lukas Saya tidak peduli dengan tampilan tetapi saya ingin menghindari mengulangi position:absolute;.
Neil
12

PowerShell, 67 66 Bytes

for($s='.'*4+' '*6;$s=-join($s[,9+0..8])){cls;"[$s]";sleep -m 100}

-1 dengan menggunakan konstruktor yang dipersingkat berkat Beatcracker

mengganti string dengan salinan string di mana karakter terakhir diletakkan di depan karakter yang tersisa, membersihkan layar, mencetaknya, dan kemudian tidur selama 100 ms.

menyimpan banyak byte dengan menggunakan konstruktor for loop daripada membungkus logika di dalam string.

masukkan deskripsi gambar di sini

colsw
sumber
1
+1 untuk fortrik lingkaran dan membuat saya membaca kembali about_Join .
beatcracker
1
PS Anda dapat menggunakan satu byte lagi menggunakan golf $s='.'*4+' '*6.
beatcracker
@beatcracker, terima kasih untuk itu - diperbarui :)
colsw
Script tidak dimulai oleh [.... ]. Anda dapat memperbaikinya tanpa penalti:for($s='.'*4+' '*6){cls;"[$s]";$s=-join($s[,9+0..8]);sleep -m 100}
mazzy
10

Python 3 , 99 93 85 83 + 2 ( -u flag ) byte

-12 byte terima kasih kepada ovs
-2 byte terima kasih untuk benar-benar manusiawi

import time
s=4*'.'+6*' '
while 1:print(end='\r[%s]'%s);time.sleep(.1);s=s[9]+s[:9]

Cobalah online!

tongkat
sumber
Mengapa Anda memiliki flush=True? Ini bekerja tanpa untuk saya
L3viathan
3
@ L3viathan karena terminal (ubuntu) saya tidak memerah. Perilaku memerah ini tergantung pada OS = /
Rod
1
Simpan beberapa byte denganprint(end='\r[%s]'%s,flush=1)
ovs
2
Anda dapat menghapus flush seluruhnya dengan menggunakan -ubendera baris perintah. Pertanyaan terkait SO
ovs
1
Anda juga dapat menyimpan beberapa byte s[9]+s[:9].
totallyhuman
10

Windows batch, 201 181 byte

Ternyata menggunakan metode old-school sebenarnya menghemat byte!

@for %%p in ("....      " " ....     " "  ....    " "   ....   " "    ....  " "     .... " "      ...." ".      ..." "..      .." "...      .")do @echo [%%~p]&timeout 0 >nul&cls
@%0

catatan:

get-screenrecorder.level
- low grade

get-gpu.level
- horrible

if get-screenrecorder.level == low grade || get-gpu.level == horrible {
     say("GIF may not be accurate");
}

GIF!

Harap dicatat bahwa perekam GIF saya melewatkan beberapa bingkai, membuat bilah pemuatan melonjak :(

stevefestl
sumber
1
Daripada menghitung jumlah titik, jika Anda hanya menyimpan variabel dengan titik-titik dan spasi dan melakukan manipulasi string, Anda mungkin bisa mendapatkan ini hingga 100 byte.
Neil
Saya akan mencoba mengerjakan ini, terima kasih atas tipsnya :)!
stevefestl
timeout / t 0> nul bukannya ping 1.1 -n 1 -w 100> nul akan berada dalam persyaratan waktu 100ms +/- 250ms (harus sekitar 25 - 100ms secara normal) sehingga dapat menghemat beberapa byte di sana ( ss64.com/ nt / timeout.html )
Liam Daly
1
Juga menghapus @echo offdan mengganti do dengan do @(echo %%~p&timeout/t 0 >nul&cls)juga akan berfungsi dan harus menyimpan 11 karakter (200 byte di komputer saya)
Liam Daly
8

Mathematica, 67 77 Bytes

+10 Bytes karena saya lupa tanda kurung.

Animate["["<>"....      "~StringRotateRight~n<>"]",{n,1,10,1},RefreshRate->10]
Ian Miller
sumber
1
Sungguh, Mathematica memiliki built-in Animate? : |
Tn. Xcoder
Ya, itu akan menghidupkan hampir semua variabel yang diberikan. :)
Ian Miller
Ini sepertinya tidak termasuk tanda kurung segi empat yang dilakukan sebagian besar jawaban lainnya.
Mark S.
Oh tikus, tidak melihat cukup dekat. Ok diperbaiki.
Ian Miller
8

C (gcc) , 126 125 124 123 122 121 119 118 117 114 115 byte

Yang ini menggunakan bitmask untuk melacak di mana titik-titiknya.

Saya harus menambahkan byte lain karena saya hanya menghasilkan 5 spasi sebelumnya.

m=30;f(i){usleep(3<<15);system("clear");for(i=1;i<1920;i*=2)putchar(i^1?i&m?46:32:91);m+=m&512?m+1:m;f(puts("]"));}

Cobalah online!

masukkan deskripsi gambar di sini

Cleblanc
sumber
48
MENGAPA font perintah prompt Anda Comic Sans MS?!?!?!
MD XF
7

Javascript (ES6), 86 byte

setInterval('with(console)clear(),log(`[${x=x[9]+x.slice(0,9)}]`)',100,x='...      .')

nderscore
sumber
4
+1 untuk with. Selalu beri +1 untuk with!
Shaggy
@Shaggy codegolf.stackexchange.com/questions/118402/... #SelfPromotion: p
Arjun
6

JavaScript (ES6) + HTML, 104 85 83 byte

f=(s="....      ")=>setTimeout(f,100,s[9]+s.slice(0,9),o.value=`[${s}]`)
<input id=o
  • Disimpan 2 byte berkat saran Johan bahwa saya menggunakan inputbukan pre.

Try It

Membutuhkan penutupan > on the input tag in order to function in a Snippet.

(f=(s="....      ")=>setTimeout(f,100,s[9]+s.slice(0,9),o.value=`[${s}]`))()
<input id=o>

Shaggy
sumber
1
Bukankah seharusnya ada 10 karakter di antara karakter []?
Neil
Anda benar, @Neil; ada 6 ruang - jika saya akan menghitung hal-hal dengan mata, yang paling bisa saya lakukan adalah memakai kacamata saya!
Shaggy
1
Can't you use an <input> instead of <pre>and then value instead of innerText?
Johan Karlsson
Good call, @JohanKarlsson; that saves 2 bytes.
Shaggy
Hey! This is the same byte count: s='.... ';setInterval(f=>{o.value='[${s=s[9]+s.slice(0,9)}]'},100);<input id=o, maybe someone can improve it (replace quotation mark with `)
Thomas W
5

Noodel, 16 15 14 13 bytes

[ CỤ‘Ṁ~ððÐ]ʠḷẸḍt

]ʠ[Ð.×4¤×6⁺ḷẸḍt

]ʠ⁶¤⁴.ȧ[ėÐḷẸḍt

Try it:)


How it works

]ʠ⁶¤⁴.ȧ[ėÐḷẸḍt

]ʠ⁶¤⁴.ȧ[ėÐ     # Set up for the animation.
]              # Pushes the literal string "]" onto the stack.
 ʠ             # Move the top of the stack down by one such that the "]" will remain on top.
  ⁶¤           # Pushes the string "¤" six times onto the stack where "¤" represents a space.
    ⁴.         # Pushes the string "." four times onto the stack.
      ȧ        # Take everything on the stack and create an array.
       [       # Pushes on the string literal "[".
        ė      # Take what is on the top of the stack and place it at the bottom (moves the "[" to the bottom).
         Ð     # Pushes the stack to the screen which in Noodel means by reference.

          ḷẸḍt # The main animation loop.
          ḷ    # Loop endlessly the following code.
           Ẹ   # Take the last character of the array and move it to the front.
            ḍt # Delay for a tenth of a second.
               # Implicit end of loop.

Update

[Ð]ıʠ⁶¤⁴.ḷėḍt

Try it:)

Don’t know why this took me a while to think of. Anyways, this places it at 13 bytes.

[Ð]ıʠ⁶¤⁴.ḷėḍt

[Ð]ıʠ⁶¤⁴.     # Sets up the animation.
[             # Push on the character "["
 Ð            # Push the stack as an array (which is by reference) to the screen.
  ]           # Push on the character "]"
   ı          # Jump into a new stack placing the "[" on top.
    ʠ         # Move the top of the stack down one.
     ⁶¤       # Push on six spaces.
       ⁴.     # Push on four dots.

         ḷėḍt # The main loop that does the animation.
         ḷ    # Loop the following code endlessly.
          ė   # Take the top of the stack and put it at the bottom.
           ḍt # Delay for a tenth of a second.

<div id="noodel" code="[Ð]ıʠ⁶¤⁴.ḷėḍt" input="" cols="12" rows="2"></div>

<script src="https://tkellehe.github.io/noodel/noodel-latest.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>

tkellehe
sumber
2
Never heard of Noodel before, but it seems to be the right tool for the right job! +1
Kevin Cruijssen
1
@KevinCruijssen, ETHProductions has a good list with languages for code golfing:)
tkellehe
6
Just when I thought I outgolfed you, I notice you have already golfed your solution twice
Kritixi Lithos
@KritixiLithos, I was scared you were going to beat me so I spent forever trying to get to 14 bytes. But, now you are close again!! Dang!!
tkellehe
1
@nitro2k01 Noodel uses its own code-page with 256 characters, which are all saved as a single byte in their own encoding. Similar as some other golfing languages do, like Jelly or 05AB1E. If you would save these characters as default UTF-8 encoding, they will indeed be 2 or 3 bytes instead, but in their own encoding they are 1 byte each.
Kevin Cruijssen
4

PHP, 67 bytes

for($s="...      .";$s=substr($s.$s,9,10);usleep(1e5))echo"\r[$s]";

no comment

Titus
sumber
4

C#, 162 157 bytes

()=>{for(string o="[....      ]";;){o=o.Insert(1,o[10]+"").Remove(11,1);System.Console.Write(o);System.Threading.Thread.Sleep(100);System.Console.Clear();}};

or as whole program for 177 bytes

namespace System{class P{static void Main(){for(string o="[....      ]";;){o=o.Insert(1,o[10]+"").Remove(11,1);Console.Write(o);Threading.Thread.Sleep(100);Console.Clear();}}}}
LiefdeWen
sumber
+1 Something to golf: for(string o="[.... ]";;) can be golfed to var o="[.... ]";for(;;). Or you can us a port of my Java 7 answer to golf the total some more: ()=>{var o=".... "for(;;){o=(o+o).Substring(9,10);System.Console.Write("["+o+"]\n");System.Threading.Thread.Sleep(100);System.Console.Clear();}};
Kevin Cruijssen
Would string interpolation trim anymore off? Something like $"[{o}]\n"
Marie
1
If you replace System.Console.Write(o) with System.Console.Write(o+"\r") you can remove the System.Console.Clear();
grabthefish
4

Pure bash, 68

s=${1:-....      }
printf "[$s]\r"
sleep .1
exec $0 "${s: -1}${s%?}"
Digital Trauma
sumber
4

MATL, 24 bytes

`1&Xx'['897B@YS46*93hhDT

Try it at MATL Online! Or see a gif from the offline compiler:

enter image description here

Explanation

`        % Do...while
  1&Xx   %   Pause for 0.1 s and clear screen
  '['    %   Push this character
  897B   %   Push [1 1 1 0 0 0 0 0 0 1]
  @      %   Push current iteration index, 1-based
  YS     %   Circularly shift the array by that amount
  46*    %   Multiply by 46 (code point of '.')
  93     %   Push 93 (code point of ']')
  hh     %   Concatenate horizontally twice. Numbers are interpreted as chars
         %   with the corresponding code points
  D      %   Display
  T      %   Push true. Used as loop condition. Results in an infinite loop
         % End (implicit)
Luis Mendo
sumber
Your link crashes, meaning that I cannot kill it.
Leaky Nun
1
@LeakyNun What do you mean exactly that it crashes? It works for me, and I can kill it. Sometimes there are timeout issues. If it doesn't start, try refreshing the page
Luis Mendo
4

Jelly, 28 27 bytes

ṙ©-j@⁾[]ṭ”ÆȮœS.1®ß
897ṃ⁾. Ç

Example run

How?

ṙ©-j@⁾[]ṭ”ÆȮœS.1®ß - Link 1, the infinite loop: list of characters s
ṙ                  - rotate s left by:
  -                -   -1 (e.g. "...      ." -> "....      ")
 ©                 -   copy to the register and yield
     ⁾[]           - literal ['[',']']
   j@              - join with reversed @rguments
         Ӯ        - literal '\r'
        ṭ          - tack (append the display text to the '\r')
           Ȯ       - print with no newline ending
              .1   - literal 0.1
            œS     - sleep for 0.1 seconds then yield the printed text (unused)
                ®  - recall the value from the register
                 ß - call this link (1) again with the same arity

897ṃ⁾. Ç - Main link: no arguments
897      - literal 897
    ⁾.   - literal ['.',' ']
   ṃ     - base decompression: convert 897 to base ['.',' '] = "...      ."
Jonathan Allan
sumber
4

C (gcc), 202 198 196 189 96 99 88 86 79 77 75 74 73 bytes

Saved 7 8 bytes thanks to Digital Trauma.

f(i){usleep(dprintf(2,"\r[%-10.10s]","....      ...."+i%10)<<13);f(i+9);}

Or, if your system's stdout doesn't need to be flushed after every write without a newline:

C (gcc), 70 bytes

f(i){usleep(printf("\r[%-10.10s]","....      ...."+i%10)<<13);f(i+9);}

How it works

  • usleep( sleeps for the next return value in microseconds.
  • dprintf(2, prints to file descriptor 2, or stderr. This is necessary because while stdout is line-buffered (meaning output will not show until it prints a newline), stderr is character-buffered (all output is shown immediately).
  • "\r prints a carriage return (clears the current line).
  • [%-10.10s]" is the printf format specifier for a string with exact length 10 (no matter what string provided the output will always be a string with length 10), padded with spaces to the right if necessary. This will be enclosed with brackets.
  • ".... ...." is the loading bar.
  • +i%10 offsets the loading bar by the current index modulo 10. For example, if i == 3, i % 10 is equal to 3. Offsetting the loading bar by 3 makes it equal to ". ....".
  • When the offset-ed string is passed to the printf format specifier, it limits to a length of 10 if necessary and adds spaces to the end if necessary. Therefore, the loading bar will always be between [.... ] and [. ...].
MD XF
sumber
i;f(){for(;;i=++i%10)usleep(7500*dprintf(2,"\r[%-10.10s]",".... ...."-i+10));} should work.
Christoph
1
Great golfing! Save 1 more byte with f(i){usleep(dprintf(2,"\r[%-10.10s]",".... ...."+i%10)<<13);f(i+9);}
Digital Trauma
@DigitalTrauma The spaces in your code didn't render properly. However, I see what you meant, and thanks for the help!
MD XF
3

Java 7, 139 124 bytes

String s="....      ";void c()throws Exception{System.out.print("["+s+"]\r");s=(s+s).substring(9,19);Thread.sleep(100);c();}
  • Mentioning of \r thanks to @Phoenix.

The carriage return \r resets the 'cursor' back to the begin of the line, which can then be overwritten. Unfortunately, online compilers nor the Eclipse IDE doesn't support this, so I've added a gif at the end of this answer to show it from Windows Command Prompt.

Try it here. (Slightly modified so you won't have to wait for the time-out before viewing the result. Also, the TIO doesn't support carriage returns, so every line is printed without overwriting the previous line.)

Explanation:

String s="....      ";            // Starting String "....      " on class level
void c()                          // Method without parameter nor return-type
 throws Exception{                // throws-clause/try-catch is mandatory for Thread.sleep
  System.out.print("["+s+"]\r");  //  Print the String between square-brackets,
                                  //  and reset the 'cursor' to the start of the line
  s=(s+s).substring(9,19);        //  Set `s` to the next String in line
  Thread.sleep(100);              //  Wait 100 ms
  c();                            //  Recursive call to same method
}                                 // End of method

Output gif:

enter image description here

Kevin Cruijssen
sumber
You can clear the line by replacing println with print and outputting a carriage return. Might not work in your IDE's terminal, but it would work in any other sane one.
Pavel
@Phoenix By carriage return you mean \r\n? How does System.out.print(someString+"\r\n); clear the console.. It's the same as using System.out.println(someString);.. It simply goes to the next line, but doesn't remove any previous line printed.. :S
Kevin Cruijssen
4
No, I mean \r, without \n. That resets the "cursor" to the beginning of the line so printing anything will overwrite that line.
Pavel
@Phoenix Ah of course. Thanks. Modified my answer and added a gif to show the result. Too bad online compilers nor the Eclipse IDE aren't supporting this.. >.>
Kevin Cruijssen
3

Python 2, 81 78 bytes

-1 byte (noticing I missed use of %s when Rod submitted an almost identical Python 3 version at the same time!)
-2 bytes (using totallyhuman's idea - replace s[-1]+s[:-1] with s[9]+s[:9])

import time
s='.'*4+' '*6
while s:print'\r[%s]'%s,;s=s[9]+s[:9];time.sleep(.1)

Example run

Jonathan Allan
sumber
How it's flushing the output? this is the reason why I'm using python3 on my answer (it would take more bytes to flush on python2)
Rod
@Rod the \r overwrites the line and the , makes it print a tuple rather than a string - I saw it a while back somewhere and have used it before too.
Jonathan Allan
1
Yes, this is what I was doing, but the output wasn't being printed in real time (had to use sys.stdout.flush())
Rod
1
Found the culprit : my ubuntu terminal :c
Rod
3

Go, 150 145 132 129 124 bytes

-5 bytes thanks to sudee.

I feel like I don't see enough Go here... But my answer is topping C so... pls halp golf?

package main
import(."fmt"
."time")
func main(){s:="....      ";for{Print("\r["+s+"]");Sleep(Duration(1e8));s=(s+s)[9:19];}}

Try it online!

totallyhuman
sumber
1
Not familiar with Go, but I would assume you can convert 100000000 to 10^8 to save 5 bytes.
Grant Miller
@goatmeal I tried that but it's apparently bitwise negation. I also tried 10**8 which also gives an error.
totallyhuman
3
You can use scientific notation: 1e8.
sudee
1
@sudee Aha, that would be the way to use large numbers. Thanks!
totallyhuman
2
@MDXF I should've phrased that differently, I meant my answer is being out-golfed by C.
totallyhuman
3

VBA 32-bit, 159 157 143 141 134 Bytes

VBA does not have a built in function that allows for waiting for time periods less than one second so we must declare a function from kernel32.dll

32 Bit Declare Statement (41 Bytes)

Declare Sub Sleep Lib"kernel32"(ByVal M&)

64 Bit Declare Statement (49 Bytes)

Declare PtrSafe Sub Sleep Lib"kernel32"(ByVal M&)

Additionally, we must include a DoEvents flag to avoid the infinite loop from making Excel appear as non-responsive. The final function is then a subroutine which takes no input and outputs to the VBE immediate window.

Immediate Window function, 93 Bytes

Anonymous VBE immediate window function that takes no input and outputs to the range A1 on the ActiveSheet

s="...      ....      .":Do:DoEvents:Sleep 100:[A1]="["&Mid(s,10-i,10)&"]":i=(i+1)Mod 10:Loop

Old Version, 109 Bytes

Immediate window function that takes no input and outputs to the VBE immediate window.

s="...      ....      .":i=0:Do:DoEvents:Sleep 100:Debug.?"["&Mid(s,10-i,10)&"]":i=(i+1) Mod 10:Loop

Ungolfted and formatted

Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal M&)
Sub a()
    Dim i As Integer, s As String
    s = "...      ....      ."
    i = 0
    Do
        Debug.Print [REPT(CHAR(10),99]; "["; Mid(s, 10 - i, 10); "]"
        DoEvents
        Sleep 100
        i = (i + 1) Mod 10
    Loop
End Sub

-2 Bytes for removing whitespace

-30 Bytes for counting correctly

-14 Bytes for converting to immediate window function

Output

The gif below uses the full subroutine version because I was too lazy to rerecord this with the immediate window function.

VBA loading Gif

Taylor Scott
sumber
What's that a at the top of the output?
MD XF
@MDXF that is the call to run subroutine a as is listed above; this is functionally equivalant to the more verbose call a().
Taylor Scott
Ah, my bad. Just looking for bad submissions. Your's isn't, then, so +1
MD XF
2

05AB1E, 23 bytes

'.4×ð6×J[D…[ÿ],Á¶т×,т.W

Try it online!

Explanation

'.4×ð6×J                  # push the string "....      "
        [                 # forever do:
         D                # duplicate
          …[ÿ],           # interpolate the copy between brackets and print
               Á          # rotate the remaining copy right
                ¶т×,      # print 100 newlines
                    т.W   # wait 100ms
Emigna
sumber
2

Batch, 99 98 bytes

Saved 1 byte thanks to SteveFest!

(I could remove \r from the code, but in the spirit of batch golfing, I won't.)

@SET s=....      
:g
@CLS
@ECHO [%s%]
@SET s=%s:~-1%%s:~,-1%
@ping 0 -n 1 -w 100>nul
@GOTO g

Recorded with LICEcap

There are four spaces after the first line.

The main logic is modifying the string. %s:~-1% is the last character of %s% and %s:~0,-1% is all but the last character of %s%. Thus, we are moving the last character to the front of the string, which rotates the string.

Conor O'Brien
sumber
Aw... I've been looking for this...
stevefestl
1
Golf 1 byte: the 0 in the variable substring can be removed
stevefestl
You use cmder. Nice job.
MD XF
1
@SteveFest Huh, TIL. Thanks!
Conor O'Brien
1
@MDXF It's the only reason I'm still sane :P
Conor O'Brien
2

Ruby, 57 56 bytes

s=?.*4+' '*6;loop{$><<"[%s]\r"%s=s[-1]+s.chop;sleep 0.1}

Heavily influenced by other answers here.

Saved a byte thanks to @manatwork. Also apparently I have trouble counting characters -- I use ST3 and apparently it will include newlines in the count of characters in the line if you're not attentive.

canhascodez
sumber
How does it work? Does this assume that the input is stored in s?
Rɪᴋᴇʀ
@Riker He defines s at the beginning of the program as 4 .s and a few spaces
Conor O'Brien
s[0..8]s.chop
manatwork
2

Perl, 69 bytes

-3 bytes thanks to @Dom Hastings.

$_="....".$"x6;{print"\ec[$_]
";select$a,$a,!s/(.*)(.)/$2$1/,.1;redo}

That select undef,undef,undef,.1 is the shortest way to sleep less than 1 second in Perl, and it takes a lot of bytes...


Slightly longer (79 bytes), there is:

@F=((".")x4,($")x6);{print"\ec[",@F,"]\n";@F=@F[9,0..8];select$a,$a,$a,.1;redo}
Dada
sumber
Evening, managed to get this down a little more 69 (or 68 with a literal ESC): gist.github.com/dom111/e3ff41c8bc835b81cbf55a9827d69992 I feel like the tried to use !print but you need parens so it ends up the same length :/
Dom Hastings
@DomHastings Nice, thanks! You still know how to golf :D
Dada
2

Bash, 93 90 96 bytes

s="...      ....      ."
for((;;)){ for i in {0..9};do printf "\r[${s:10-i:10}]";sleep .1;done;}

view here

couldn't get nested { } in for syntax

marcosm
sumber
I intended to post a quite similar solution, but is pointless now. But may give some inspiration to improve your: pastebin.com/Ld6rryNX
manatwork
much better! i'm not stealing from you, i knew i had to work out this one...
marcosm
edited, printf padding can't help in shortening s. wraping the string as @DigitalTrauma looks better.
marcosm
1

Groovy, 72 bytes

s="*"*4+" "*6
for(;;){print("["+s+"]"+"\n"*20);s=s[9]+s[0..8];sleep 100}

Explaination

s="*"*4+" "*6 //creates the string "****      "
for(;;){ //classic infinite loop
    print("["+s+"]"+"\n"*20) //prints the string with [ at the beginning and ] at the end. After that some newlines
    s=s[9]+s[0..8] //appends the final char of the string to beginning, creating a cycling illusion
    sleep 100 //100 ms delay
}
staticmethod
sumber
Didn't know a proper way to clear the console in Groovy/Java. If someone has a way of doing it, please tell me
staticmethod
1
You can use \r to return the cursor to the start of the line. It appears that at least several answers are doing this. From there, you could delete the *20, saving 3 bytes.
phyrfox
1

Haskell (Windows), 159 bytes

import System.Process
import Control.Concurrent
main=mapM id[do system"cls";putStrLn('[':["....      "!!mod(i-n)10|i<-[0..9]]++"]");threadDelay(10^5)|n<-[0..]]

Explanation

mapM id             sequentially perform each IO action in the following list
[                   start a list comprehension where each element is...
  do                  an IO operation where
    system "cls";       we clear the screen by calling the windows builtin "cls"
    putStrLn(           then display the string...
      '[':                with '[' appended to
      [                   a list comprehension where each character is...
        "....      "!!       the character in literal string "....      " at the index
        mod(i-n)10          (i - n) % 10
      |i<-[0..9]]         where i goes from 0 to 9
      ++"]"             and that ends with ']'
    );
    threadDelay(10^5)   then sleep for 100,000 microseconds (100 ms)
|n<-[0..]]          where n starts at 0 and increments without bound

Haskell's purity made generating the cycling dot pattern somewhat complex. I ended up creating a nested list comprehension that generated an infinite list of strings in the order they should be output, then went back added the appropriate IO operations.


sumber
1

Ruby, 61 bytes

If the spec were for the dots to scroll left instead of right, it would save 1 byte because rotate! with no arguments shifts the array once to the left.

s=[?.]*4+[' ']*6
loop{print ?[,*s,"]\r";s.rotate!9;sleep 0.1}
Value Ink
sumber
1

GNU sed (with exec extension), 64

Score includes +1 for -r flag.

s/^/[....      ]/
:
esleep .1
s/[^. ]*(.+)(.)].*/\c[c[\2\1]/p
b
Digital Trauma
sumber
1

c, 100

char *s="....      ....     ";main(i){for(i=0;;i=(i+9)%10)dprintf(2,"[%.10s]\r",s+i),usleep(3<<15);}
Digital Trauma
sumber
Why print to stderr using dprintf and not just use printf?
MD XF
@MDXF Because by default stderr is character buffered, whereas stdout is line buffered. Since I don't want to print any \n, then with printf() I'd have to explicitly fflush(stdout) as well as #include <stdio.h>
Digital Trauma
Good point, but actually, you wouldn't have to #include <stdio.h> to flush STDOUT. fflush(0) flushes all buffers.
MD XF
1
Save three bytes by renaming main to f, that counts.
MD XF